Select programming language for code examples

linkPagination

All top-level API resources have support for bulk fetches via "list" API methods. For instance you can list users, list licenses, and list machines. These list API methods share a common format, taking an optional page query parameter.

Our API utilizes a page-based strategy via the page[size] and page[number] parameters. All results are returned in reverse chronological order.

linkQuery Parameters

  • linkpage

    object<string, integer>

    Object containing page size and page number.

  • linkpage[size]

    integer

    The page size. Must be a number between 1 and 100.

  • linkpage[number]

    integer

    The page number.

Example request

const fetch = require("node-fetch")
 
const response = await fetch("https://api.keygen.sh/v1/accounts/{ACCOUNT}/users?page[size]=25&page[number]=2", {
method: "GET",
headers: {
"Accept": "application/vnd.api+json",
"Authorization": "Bearer {TOKEN}"
}
})
 
const { data, links, errors } = await response.json()
import requests
import json
 
res = requests.get(
"https://api.keygen.sh/v1/accounts/{ACCOUNT}/users?page[size]=25&page[number]=2",
headers={
"Accept": "application/vnd.api+json",
"Authorization": "Bearer {TOKEN}"
}
).json()
import SwiftyJSON
import Alamofire
 
Alamofire.request("https://api.keygen.sh/v1/accounts/{ACCOUNT}/users?page[size]=25&page[number]=2",
headers: [
"Accept": "application/vnd.api+json",
"Authorization": "Bearer {TOKEN}"
]
).responseJSON { response in
let json = JSON(data: response.data!)
}
using RestSharp;
 
var client = new RestClient("https://api.keygen.sh/v1/accounts/{ACCOUNT}");
var request = new RestRequest("users", Method.GET);
 
request.AddHeader("Accept", "application/vnd.api+json");
request.AddHeader("Authorization", "Bearer {TOKEN}");
 
request.AddParameter("page[size]", 25);
request.AddParameter("page[number]", 2);
 
var response = client.Execute(request);
import com.mashape.unirest.http.exceptions.*
import com.mashape.unirest.http.*
 
val res = Unirest.get("https://api.keygen.sh/v1/accounts/{ACCOUNT}/users")
.header("Authorization", "Bearer {TOKEN}")
.header("Accept", "application/vnd.api+json")
.queryString("page[size]", 25)
.queryString("page[number]", 2)
.asJson()
import com.mashape.unirest.http.exceptions.*;
import com.mashape.unirest.http.*;
 
HttpResponse<JsonNode> res = Unirest.get("https://api.keygen.sh/v1/accounts/{ACCOUNT}/users")
.header("Authorization", "Bearer {TOKEN}")
.header("Accept", "application/vnd.api+json")
.queryString("page[size]", 25)
.queryString("page[number]", 2)
.asJson();
#include <iostream>
#include <string>
#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
 
using namespace std;
using namespace web;
using namespace web::http;
using namespace web::http::client;
using namespace utility;
 
http_client client("https://api.keygen.sh/v1/accounts/{ACCOUNT}");
http_request req;
 
req.headers().add("Authorization", "Bearer {TOKEN}");
req.headers().add("Accept", "application/json");
 
uri_builder uri("/users");
uri.append_query("page[size]", 25);
uri.append_query("page[number]", 2);
 
req.set_request_uri(uri.to_uri());
req.set_method(methods::GET);
 
client.request(req)
.then([](http_response res) {
auto data = res.extract_json().get();
})
.wait();
curl 'https://api.keygen.sh/v1/accounts/{ACCOUNT}/users?page[size]=25&page[number]=2' -g \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer {TOKEN}'

Example response

{
"data": [
{
"id": "6ed498fe-5f5f-49af-82ee-cb7400cc4522",
"type": "users",
"links": {
"self": "/v1/accounts/{ACCOUNT}/users/6ed498fe-5f5f-49af-82ee-cb7400cc4522"
},
"attributes": {
"fullName": "Marty McFly",
"firstName": "Marty",
"lastName": "McFly",
"email": "[email protected]",
"role": "user",
"metadata": {},
"created": "2017-01-02T19:48:50.077Z",
"updated": "2017-01-02T19:48:50.077Z"
},
"relationships": {
"account": {
"links": {
"related": "/v1/accounts/{ACCOUNT}"
},
"data": {
"type": "accounts",
"id": "{ACCOUNT}"
}
},
"products": {
"links": {
"related": "/v1/accounts/{ACCOUNT}/users/a5a154d2-f026-40fa-bc8d-a7e3ca415298/products"
}
},
"licenses": {
"links": {
"related": "/v1/accounts/{ACCOUNT}/users/a5a154d2-f026-40fa-bc8d-a7e3ca415298/licenses"
}
},
"machines": {
"links": {
"related": "/v1/accounts/{ACCOUNT}/users/a5a154d2-f026-40fa-bc8d-a7e3ca415298/machines"
}
},
"tokens": {
"links": {
"related": "/v1/accounts/{ACCOUNT}/users/a5a154d2-f026-40fa-bc8d-a7e3ca415298/tokens"
}
}
}
},
],
"links": {
"self": "/v1/accounts/{ACCOUNT}/users?page[size]=25&page[number]=2",
"prev": "/v1/accounts/{ACCOUNT}/users?page[size]=25&page[number]=1",
"next": "/v1/accounts/{ACCOUNT}/users?page[size]=25&page[number]=3",
"first": "/v1/accounts/{ACCOUNT}/users?page[size]=25&page[number]=1",
"last": "/v1/accounts/{ACCOUNT}/users?page[size]=25&page[number]=4",
"meta": {
"pages": 4,
"total": 98
}
}
}