1. API Keys
  2. Retrieve API Keys

API Keys

Retrieve API Keys

Retrieve API Key

GET
`/v1/api-keys/:api-key`

Retrieve an api key using its id.

js
        const response = await fetch(`https://api.packagex.io/v1/api-keys/${api_key}`, {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
}).then((res) => res.json());

const key = response.data;

      

List API Keys

This endpoint allows you to retrieve multiple API Keys associated with your organization. The response will always include a data array containing the API Keys, even if no keys are found.

GET
`/v1/api-keys`
js
        const response = await fetch(`https://api.packagex.io/v1/api-keys`, {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
}).then((res) => res.json());

const api_keys = response.data;
const pagination = response.pagination;

      

Filtering

Use the types query parameter to filter API Keys by type. You can specify user, system, or both (comma-separated).

js
        const response = await fetch(`https://api.packagex.io/v1/api-keys?type=user,system`, {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
}).then((res) => res.json());

const api_keys = response.data;
const pagination = response.pagination;

      

Pagination

The response includes a pagination object with the following properties:

  • has_more - Indicates if there are more api keys available
  • page - Current page number (default: 1)
  • limit - Number of results per page (default: 25)
  • total_count - Total number of api keys in the database.

To retrieve the next page of results:

js
        const response = await fetch("https://api.packagex.io/v1/api-keys?page=2&limit=25", {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  }
}).then((res) => res.json());

const api_keys = response.data;
const pagination = response.pagination;

      

Sorting

Control the order of results using:

Parameter Type Default Description
order_by string created_at Field to sort by, supported values: name, created_at, updated_at
direction string asc Sort direction, supported values: asc, desc

If no sorting parameter is specified, the system defaults to sorting by name in ascending order asc

Example with sorting:

js
        const response = await fetch(`https://api.packagex.io/v1/api-keys?order_by=updated_at&direction=desc`, {
  method: "GET",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  }
}).then((res) => res.json());

const api_keys = response.data;
const pagination = response.pagination;