1. API Keys
  2. Retrieve API Keys

API Keys

Retrieve API Keys

Retrieve API Key

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

Get a single contact using its id.

js
        const response = await fetch("https://api.packagex.io/v1/api-keys/key_99N7wCTRBtZCgCiYKcMyV1", {
  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

Example

GET
`/v1/api-keys`

When you want to retrieve multiple API Keys, your data property on the result will always be an array even if you don't have any 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;

      

Pagination

If the has_more property on the pagination object is set to true, you know there are more API keys in the database that have not been returned to you. The pagination object also has a page property indicating your current offset and a limit property. The total_count property in pagination returns the the total number of API Keys in the database.

By default the page is set to 1 and the limit is 25.

If we want to query for keys 26 - 50, we would request page 2 with a query parameter.

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 keys = response.data; //the array of keys 25 - 50
const pagination = response.pagination; //the pagination object