API

The privatepkgs API gives you access to interact with your own private package registry.

Authentication

To properly interact with the API, you must use the Bearer authentication scheme. Each request should have the Authorization header with your API token.

Endpoints

The API exposes a variety of endpoints under the URL https://api.privatepkgs.com and generally follows the REST architecture.

Licenses

Gets a paginated list of licenses

GET/v1/licenses
Query parameters
sincestring
optional
The timestamp to start from
untilstring
optional
The timestamp to end at
Response
200List of licenses
{
  "pagination": {
    "count": 1,
    "prev": null,
    "next": 1696674097584
  },
  "data": [
    {
      "id": "19cb44f0-9016-43c4-b73b-6f0fb34c755f",
      "name": "Default License",
      "key": "12345-12345-ABCDE",
      "suspended": false,
      "meta": {
        "key": "value"
      },
      "packages": [
        "example-package"
      ],
      "createdAt": 1672531200000,
      "updatedAt": 1672531200000
    }
  ]
}

Creates a new license

POST/v1/licenses
Body parameters
namestring
optional
The name of the license
Example:
Default License
keystring
optional
The unique key of the license. Defaults to a randomly generated key.
Example:
12345-12345-ABCDE
constraintobject
required
No restrictions:
typestring
required
The type of constraint
Example:
none
Restriction based on date:
typestring
required
The type of constraint
Example:
date
valuenumber
required
Timestamp in milliseconds until the license is valid
Example:
1697095609643
Restriction based on version:
typestring
required
The type of constraint
Example:
version
valuestring
required
The semver constraint
Example:
<2.0.0
suspendedboolean
optional
Whether the license is suspended or not
Example:
false
metaobject
optional
Any additional data to store with the license
Example:
{"key":"value"}
packagesarray
required
The packages the license applies to
Example:
["example-package"]
Response
201Created license
{
  "id": "19cb44f0-9016-43c4-b73b-6f0fb34c755f",
  "name": "Default License",
  "key": "12345-12345-ABCDE",
  "constraint": {
    "type": "none"
  },
  "suspended": false,
  "meta": {
    "key": "value"
  },
  "packages": [
    null
  ],
  "createdAt": 1672531200000,
  "updatedAt": 1672531200000
}

Gets a license by id

GET/v1/licenses/{id}
Path parameters
idstring
required
The id of the license
Response
200License
{
  "id": "19cb44f0-9016-43c4-b73b-6f0fb34c755f",
  "name": "Default License",
  "key": "12345-12345-ABCDE",
  "constraint": {
    "type": "none"
  },
  "suspended": false,
  "meta": {
    "key": "value"
  },
  "packages": [
    null
  ],
  "createdAt": 1672531200000,
  "updatedAt": 1672531200000
}

Updates a license

PUT/v1/licenses/{id}
Path parameters
idstring
required
The id of the license
Body parameters
namestring
required
The name of the license
Example:
Default License
keystring
required
The unique key of the license
Example:
12345-12345-ABCDE
constraintobject
required
No restrictions:
typestring
required
The type of constraint
Example:
none
Restriction based on date:
typestring
required
The type of constraint
Example:
date
valuenumber
required
Timestamp in milliseconds until the license is valid
Example:
1697095609643
Restriction based on version:
typestring
required
The type of constraint
Example:
version
valuestring
required
The semver constraint
Example:
<2.0.0
suspendedboolean
required
Whether the license is suspended or not
Example:
false
metaobject
optional
Any additional data to store with the license
Example:
{"key":"value"}
packagesarray
required
The packages the license applies to
Example:
["example-package"]
Response
200Updated license
{
  "id": "19cb44f0-9016-43c4-b73b-6f0fb34c755f",
  "name": "Default License",
  "key": "12345-12345-ABCDE",
  "constraint": {
    "type": "none"
  },
  "suspended": false,
  "meta": {
    "key": "value"
  },
  "packages": [
    null
  ],
  "createdAt": 1672531200000,
  "updatedAt": 1672531200000
}

Removes a license

DELETE/v1/licenses/{id}
Path parameters
idstring
required
The id of the license
Response
204License was removed