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
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 requestsimport jsonres = 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 SwiftyJSONimport AlamofireAlamofire.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 inlet 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", "status": "ACTIVE", "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, "count": 98 } }}