Agari Developer Documentation

Agari Developer Documentation

API Overview & Guide
Get started
Interactive API Reference
Get started

Quick Start

Get started quickly with the Agari APIs

At a high level, getting started with the APIs involves the following steps:

  1. Get Agari API account
  2. Generate API credentials
  3. Generate an API access token
  4. Use the API

We'll walk through each step in detail below.

Get Agari API account

  1. Ensure you have an active Agari account

🚧

Ensure you already have an active Agari account

You won't get very far if you don't already have an active Agari account set up.

Contact us if you don't already have an account.

Generate API Credentials

Once you have your Agari account, log into the Agari product you wish to make API requests against and manually generate a client_id and client_secret:

  1. Log into your Agari product
  2. Click on your username in the upper right and select Settings
  3. Click on the Generate API Secret link to generate an API client_id and client_secret (the link will read Regenerate API Secret if you have already generated an API client ID/secret previously)
  4. Copy both the client_id and client_secret that are generated and store them somewhere safe

🚧

Keep your client_id and client_secret secure

API clients can use your client_id and client_secret to gain access to the APIs as your user. Keep these values somewhere safe and secure. Never share them with anyone.

For security purposes, the client_secret will not be displayed again, however you may generate a new one whenever needed by following the steps above.

Generate an API Access Token

Once you have generated a client_id and client_secret, generate a temporary access token to gain access to the APIs.

Note: replace YOUR_CLIENT_ID and YOUR_CLIENT_SECRET in the code below with the values generated in the prior step.

curl --request POST \
  --url https://api.agari.com/v1/ep/token \
  --header 'accept: application/json' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data 'client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET'
import requests

url = "https://api.agari.com/v1/ep/token"

payload = "client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET"
headers = {
    'accept': "application/json",
    'content-type': "application/x-www-form-urlencoded"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET");
Request request = new Request.Builder()
  .url("https://api.agari.com/v1/ep/token")
  .post(body)
  .addHeader("accept", "application/json")
  .addHeader("content-type", "application/x-www-form-urlencoded")
  .build();

Response response = client.newCall(request).execute();
var data = "client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET";

var xhr = new XMLHttpRequest();

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.agari.com/v1/ep/token");
xhr.setRequestHeader("accept", "application/json");
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");

xhr.send(data);
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.agari.com/v1/ep/token")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["accept"] = 'application/json'
request["content-type"] = 'application/x-www-form-urlencoded'
request.body = "client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET"

response = http.request(request)
puts response.read_body

Upon successful execution of your API call, the response returned will resemble the following (though the value of access_token will be unique to your request):

{
    "access_token": "49442be5e8c054437f16dc2407c76ee60afb1a3e5f0163f9e5883f72883a4985",
    "token_type": "Bearer",
    "expires_in": 14400,
    "created_at": 1592848722
}

Make a note of the access_token value in the response, as you'll pass this value in subsequent API requests to authenticate.

📘

access_token validity

The access_token is valid for 4 hours (14400 seconds). After 4 hours, request a new access token again using the steps above. See Access and Authentication for more on how to work within this constraint.

📘

Learn more about OAuth 2.0

See OAuth 2.0 to learn more.

Use the API

Having generated an access_token, you can now make API requests by including the access_token in your API requests.

The way the access_token is included depends on the programming language you are using to invoke the APIs.

export ACCESS_TOKEN="your access_token goes here"

curl --request GET \
  --url https://api.agari.com/v1/ep/users \
  --header 'accept: application/json' \
  --header "authorization: Bearer $ACCESS_TOKEN"
import requests

access_token = "your access_token goes here"

url = "https://api.agari.com/v1/ep/users"

headers = {
    'accept': "application/json",
    'authorization': "Bearer " + access_token
}

response = requests.request("GET", url, headers=headers)

print(response.text)
String accessToken = "your access_token goes here";

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.agari.com/v1/ep/users")
  .get()
  .addHeader("accept", "application/json")
  .addHeader("authorization", "Bearer " + accessToken)
  .build();

Response response = client.newCall(request).execute();
var accessToken = "your access_token goes here";

var data = null;

var xhr = new XMLHttpRequest();

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.agari.com/v1/ep/users");
xhr.setRequestHeader("accept", "application/json");
xhr.setRequestHeader("authorization", "Bearer $ACCESS_TOKEN");

xhr.send(data);
require 'uri'
require 'net/http'
require 'openssl'

access_token = "your access_token goes here"

url = URI("https://api.agari.com/v1/ep/users")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["accept"] = 'application/json'
request["authorization"] = 'Bearer ' + access_token

response = http.request(request)
puts response.read_body

Updated about a month ago



Quick Start


Get started quickly with the Agari APIs

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.