NAV
cURL Ruby Python C# PHP Java NodeJS Go

Introduction

Welcome to Testpress API. You can use our API to access Testpress API endpoints, which can get information on various resources in our database.

You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.

Authentication

To authorize, use this code:

var client = new RestClient("https://demo.testpress.in/api/v2.2/auth-token/");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n    \"username\": \"admin\",\n    \"password\": \"demo\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
re 'uri'
require 'net/http'

url = URI("https://demo.testpress.in/api/v2.2/auth-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["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request.body = "{\n    \"username\": \"testpress\",\n    \"password\": \"demo\"\n}"

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

url = "https://demo.testpress.in/api/v2.2/auth-token/"

payload = "{\n    \"username\": \"testpress\",\n    \"password\": \"demo\"\n}"
headers = {
    'content-type': "application/json",
    'cache-control': "no-cache",
    }

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

print(response.text)
# With shell, you can just pass the user credentials to get the auth token
curl --request POST \
  --url https://demo.testpress.in/api/v2.2/auth-token/ \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
  --data '{"username": "testpress", "password": "demo"}'

Make sure to replace testpress and demo with your credentials. The above command returns JSON structured like this:

<?php

$request = new HttpRequest();
$request->setUrl('http://demo.testpress.in/api/v2.2/auth-token/');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'postman-token' => '6501b66f-d9ec-4a94-0a94-ef81a66a41f3',
  'cache-control' => 'no-cache',
  'authorization' => 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTM5NTYsInVzZXJfaWQiOjEzOTU2LCJlbWFpbCI6ImRlcy5wcm8ubWFkaGFuQGhvdG1haWwuY29tIiwiZXhwIjoxNDY0MzQwMzg1fQ.TElNLpQE8KERVe7Q-vjNk9aU-9prOfzBb43srB9WmC0',
  'content-type' => 'multipart/form-data; boundary=---011000010111000001101001'
));

$request->setBody('-----011000010111000001101001
Content-Disposition: form-data; name="username"

admin
-----011000010111000001101001
Content-Disposition: form-data; name="password"

demo
-----011000010111000001101001--');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"username\"\r\n\r\nadmin\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"password\"\r\n\r\ndemo\r\n-----011000010111000001101001--");
Request request = new Request.Builder()
  .url("http://demo.testpress.in/api/v2.2/auth-token/")
  .post(body)
  .addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
  .addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTM5NTYsInVzZXJfaWQiOjEzOTU2LCJlbWFpbCI6ImRlcy5wcm8ubWFkaGFuQGhvdG1haWwuY29tIiwiZXhwIjoxNDY0MzQwMzg1fQ.TElNLpQE8KERVe7Q-vjNk9aU-9prOfzBb43srB9WmC0")
  .addHeader("cache-control", "no-cache")
  .addHeader("postman-token", "987488b1-1b5f-dd8b-95fc-fea8d276b2ae")
  .build();

Response response = client.newCall(request).execute();

{"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw"}

This endpoint provides an authentication token to get access to private resources in Testpress.

HTTP Request

POST http://demo.testpress.in/api/v2.2/auth-token/

Name Type Description
username string Username of the user
password string Password of the user

Response

The response will return an token which should be prefixed with JWT and included in all API requests to the server in a header that looks like the following:

Authorization: JWT auth-token-string

Student APIs

Student APIs provides access to all operations which can be done by a student.

Users

Users API gives you access to get basic information about other users present in the institute.

Get current authenticated user

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/me/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/me/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/me/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache'
var client = new RestClient("http://demo.testpress.in/api/v2.2/me/");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw");
IRestResponse response = client.Execute(request);

The above command returns JSON structured like this:

{
  "id": 17,
  "batches": [
    "EEE",
    "ECE",
    "Unique UPSC Batch",
    "POZITIVE ONLINE TEST SERIES",
    "OHC 2.23",
    "st std A",
    "IBPS Morning Batch",
    "UPSC Morning  Batch",
    "NEET Morning Batch",
    "IBPS Online Batch",
    "UPSC Evening Batch"
  ],
  "url": "http://demo.testpress.in/api/v2.2/users/17/",
  "username": "testpress",
  "display_name": "Divya",
  "first_name": "Divya",
  "last_name": "",
  "email": "testpress.in@gmail.com",
  "photo": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/9b69ab73fc924813871b2ef1e2ef00fa.jpeg",
  "large_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/493054067d1d4173a22d96b824d7f0c6.jpeg",
  "medium_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/8d96dab06a82487ab3149b771fe5d479.jpeg",
  "small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/4023a394cd36472fa24db76e493192ce.jpeg",
  "x_small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/796fa9a9727a42e4a7faa015b0388af3.jpeg",
  "mini_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/5f9215132af54acc8e72aed968582763.jpeg",
  "birth_date": "1994-08-27",
  "gender": "Female",
  "address1": "Chennai",
  "address2": "Chennai",
  "city": "Chennai",
  "zip": "600069",
  "state": "Tamil Nadu",
  "phone": "9043570576"
}

This endpoint retrieves details of the authenticated user.

HTTP Request

GET /api/v2.2/me/

Fields

Name Type Description
id int The user unique ID
batches array List of batches to which this user belongs
url string URL to get details of the user
username string Username of the user
first_name string First name of the user
last_name string Last name of the user
display_name string Display name of the user (Concatenates first_name & last_name if available. Falls back to username)
email string Email of the user
photo string Original photo uploaded by the user
large_image string Profile photo transformed to 256x256 px
medium_image string Profile photo transformed to 128x128 px
small_image string Profile photo transformed to 48x48 px
x_small_image string Profile photo transformed to 32x32 px
mini_image string Profile photo transformed to 24x24 px
birth_date datestring Birth date as provided by the user
gender string Gender as provided by the user. Can be “Male”, “Female” or “Transgender”
address1 string Address provided by the user
address2 string Address provided by the user
city string City provided by the user
zip string Pincode provided by the user
state string State provided by the user
phone string Phone provided by the user

Get a single user

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/users/18/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/users/18/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/users/18/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache'
var client = new RestClient("http://demo.testpress.in/api/v2.2/users/18/");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw");
IRestResponse response = client.Execute(request);

The above command returns JSON structured like this:

{
  "id": 18,
  "url": "http://demo.testpress.in/api/v2.2/users/18/",
  "username": "Vinoth",
  "display_name": "Vinoth Kumar",
  "first_name": "Vinoth",
  "last_name": "Kumar",
  "photo": "",
  "large_image": "",
  "medium_image": "",
  "small_image": "",
  "x_small_image": "",
  "mini_image": ""
}

This endpoint retrieves publicly available details of a single user.

HTTP Request

GET /api/v2.2/users/<id>

URL Parameters

Parameter Description
id The unique id of the user to retrieve

Update current user

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/users/17/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Put.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request.body = "{\n    \"first_name\": \"John\",\n    \"last_name\": \"Appleseed\"\n}"

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

url = "http://demo.testpress.in/api/v2.2/users/17/"

payload = "{\n    \"first_name\": \"John\",\n    \"last_name\": \"Appleseed\"\n}"
headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'content-type': "application/json",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request PUT \
  --url http://demo.testpress.in/api/v2.2/users/17/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
  --data '{\n    "first_name": "John",\n    "last_name": "Appleseed"\n}'
var client = new RestClient("http://demo.testpress.in/api/v2.2/users/17/");
var request = new RestRequest(Method.PUT);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw");
request.AddParameter("application/json", "{\n    \"first_name\": \"John\",\n    \"last_name\": \"Appleseed\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

The above command returns JSON structured like this:

{
  "first_name": "John",
  "last_name": "Appleseed",
  "email": "testpress.in@gmail.com",
  "photo": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/9b69ab73fc924813871b2ef1e2ef00fa.jpeg",
  "large_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/493054067d1d4173a22d96b824d7f0c6.jpeg",
  "medium_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/8d96dab06a82487ab3149b771fe5d479.jpeg",
  "small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/4023a394cd36472fa24db76e493192ce.jpeg",
  "x_small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/796fa9a9727a42e4a7faa015b0388af3.jpeg",
  "mini_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/5f9215132af54acc8e72aed968582763.jpeg",
  "x_offset": 37,
  "y_offset": 0,
  "crop_height": 540,
  "crop_width": 539,
  "birth_date": "1994-08-27",
  "gender": 2,
  "address1": "Chennai",
  "address2": "Chennai",
  "city": "Chennai",
  "zip": "600069",
  "state_choices": 31,
  "phone": "9043570576"
}

This endpoint will update a user profile details. The data to update should be posted in the request body in JSON format.

HTTP Request

PUT /api/v2.2/users/<id>

URL Parameters

Parameter Description
id The unique id of the user to retrieve

Exams

Exams API gives you access to read all the exams which can be accessed by the authenticated user.

Get All Exams

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/exams/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/exams/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'cache-control': "no-cache",
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/exams/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwidXNlcl9pZCI6MTAsImVtYWlsIjoiYmhhcmF0aEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NDc4Mjk5Nzl9.a_LVMuVyMcNQ7Qlu3w7icUYAQa9Mv2jhYikih4r-Wn8' \
  --header 'cache-control: no-cache'

The above command returns JSON structured like this:



{
  "count": 2,
  "next": null,
  "previous": null,
  "per_page": 20,
  "results": [
    {
      "url": "http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-15/",
      "id": 2394,
      "title": "Aptitude Analytical Maths (NBE Template)",
      "description": "",
      "course": "Uncategorized",
      "start_date": "2.23-08-02.27:25:22+05:30",
      "end_date": "2.29-08-01T17:25:22+05:30",
      "duration": "0:30:30",
      "number_of_questions": 20,
      "negative_marks": "0.00",
      "mark_per_question": "1.00",
      "template_type": 4,
      "allow_retake": true,
      "max_retakes": null,
      "enable_ranks": false,
      "rank_publishing_date": null,
      "attempts_url": "http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-15/attempts/",
      "allow_pdf": true,
      "created": "2.25-04-09T00:00:00Z",
      "slug": "aptitude-analytical-maths-nbe-template-15",
      "variable_mark_per_question": false,
      "show_answers": true,
      "comments_count": 0
    },
    {
      "url": "http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-16/",
      "id": 2395,
      "title": "Aptitude Analytical Maths (NBE Template)",
      "description": "",
      "course": "Uncategorized",
      "start_date": "2.23-08-02.27:25:22+05:30",
      "end_date": "2.29-08-01T17:25:22+05:30",
      "duration": "0:30:30",
      "number_of_questions": 20,
      "negative_marks": "0.00",
      "mark_per_question": "1.00",
      "template_type": 4,
      "allow_retake": true,
      "max_retakes": null,
      "enable_ranks": false,
      "rank_publishing_date": null,
      "attempts_url": "http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-16/attempts/",
      "allow_pdf": true,
      "created": "2.25-04-09T00:00:00Z",
      "slug": "aptitude-analytical-maths-nbe-template-16",
      "variable_mark_per_question": false,
      "show_answers": true,
      "comments_count": 0
    }
  ]
}

This endpoint retrieves all exams for the authenticated user.

HTTP Request

GET /api/v2.2/exams/

Query Parameters

Parameter Type Description
course string Filters by course name. Ex: IBPS
state string Indicates state of the exams to return. Can be one of: available, upcoming, history
q string Filters by exam title. Useful to search by exam title.

Get a single exam

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-15/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["cache-control"] = 'no-cache'

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

import requests

url = "http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-15/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-15/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache'

The above command returns JSON structured like this:

{
  "url": "http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-15/",
  "id": 2394,
  "title": "Aptitude Analytical Maths (NBE Template)",
  "description": "",
  "course": "Uncategorized",
  "start_date": "2.23-08-02.27:25:22+05:30",
  "end_date": "2.29-08-01T17:25:22+05:30",
  "duration": "0:30:30",
  "number_of_questions": 20,
  "negative_marks": "0.00",
  "mark_per_question": "1.00",
  "template_type": 4,
  "allow_retake": true,
  "max_retakes": null,
  "enable_ranks": false,
  "rank_publishing_date": null,
  "attempts_url": "http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-15/attempts/",
  "attempts": [
    {
      "url": "http://demo.testpress.in/api/v2.2/attempts/59591/",
      "id": 59591,
      "user": "testpress",
      "date": "2.25-07-14T05:16:12.086Z",
      "total_questions": 20,
      "score": "2.00",
      "review_url": "http://demo.testpress.in/api/v2.2/attempts/59591/review/",
      "questions_url": "http://demo.testpress.in/api/v2.2/attempts/59591/questions/",
      "percentile": 80,
      "correct_count": 2,
      "incorrect_count": 6,
      "last_started_time": "2.25-07-14T05:20:36.851Z",
      "remaining_time": "0:29:52",
      "time_taken": "0:00:38",
      "state": "Completed",
      "rank": "NA",
      "max_rank": 0,
      "percentage": "10",
      "unanswered_count": 12
    },
    {
      "url": "http://demo.testpress.in/api/v2.2/attempts/59312/",
      "id": 59312,
      "user": "testpress",
      "date": "2.25-07-13T05:07:54.639Z",
      "total_questions": 20,
      "score": "0.00",
      "review_url": "http://demo.testpress.in/api/v2.2/attempts/59312/review/",
      "questions_url": "http://demo.testpress.in/api/v2.2/attempts/59312/questions/",
      "percentile": 40,
      "correct_count": 0,
      "incorrect_count": 0,
      "last_started_time": "2.25-07-13T05:07:54.666Z",
      "remaining_time": "0:30:29",
      "time_taken": "0:00:01",
      "state": "Completed",
      "rank": "NA",
      "max_rank": 0,
      "percentage": "0",
      "unanswered_count": 20
    },
    {
      "url": "http://demo.testpress.in/api/v2.2/attempts/33827/",
      "id": 33827,
      "user": "testpress",
      "date": "2.25-05-13T13:03:53.339Z",
      "total_questions": 20,
      "score": "0.00",
      "review_url": "http://demo.testpress.in/api/v2.2/attempts/33827/review/",
      "questions_url": "http://demo.testpress.in/api/v2.2/attempts/33827/questions/",
      "percentile": 40,
      "correct_count": 0,
      "incorrect_count": 1,
      "last_started_time": "2.25-05-14T05:24:47.437Z",
      "remaining_time": "0:30:29",
      "time_taken": "0:00:01",
      "state": "Completed",
      "rank": "NA",
      "max_rank": 0,
      "percentage": "0",
      "unanswered_count": 19
    },
    {
      "url": "http://demo.testpress.in/api/v2.2/attempts/31823/",
      "id": 31823,
      "user": "testpress",
      "date": "2.25-04-21T04:47:26.454Z",
      "total_questions": 20,
      "score": "0.00",
      "review_url": "http://demo.testpress.in/api/v2.2/attempts/31823/review/",
      "questions_url": "http://demo.testpress.in/api/v2.2/attempts/31823/questions/",
      "percentile": 40,
      "correct_count": 0,
      "incorrect_count": 2,
      "last_started_time": "2.25-05-05T05:34:40.640Z",
      "remaining_time": "0:30:23",
      "time_taken": "0:00:07",
      "state": "Completed",
      "rank": "NA",
      "max_rank": 0,
      "percentage": "0",
      "unanswered_count": 18
    }
  ],
  "allow_pdf": true,
  "created": "2.25-04-09T00:00:00Z",
  "slug": "aptitude-analytical-maths-nbe-template-15",
  "variable_mark_per_question": false,
  "show_answers": true,
  "comments_count": 0
}

This endpoint retrieves a single exam.

HTTP Request

GET /api/v2.2/exams/<slug>

URL Parameters

Parameter Description
slug The unique slug of the exam to retrieve

Get Available Exams

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/exams/available/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/exams/available/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'cache-control': "no-cache",
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/exams/available/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache'

The above command returns JSON structured like this:



{
  "count": 2,
  "next": null,
  "previous": null,
  "per_page": 20,
  "results": [
    {
      "url": "http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-15/",
      "id": 2394,
      "title": "Aptitude Analytical Maths (NBE Template)",
      "description": "",
      "course": "Uncategorized",
      "start_date": "2.23-08-02.27:25:22+05:30",
      "end_date": "2.29-08-01T17:25:22+05:30",
      "duration": "0:30:30",
      "number_of_questions": 20,
      "negative_marks": "0.00",
      "mark_per_question": "1.00",
      "template_type": 4,
      "allow_retake": true,
      "max_retakes": null,
      "enable_ranks": false,
      "rank_publishing_date": null,
      "attempts_url": "http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-15/attempts/",
      "allow_pdf": true,
      "created": "2.25-04-09T00:00:00Z",
      "slug": "aptitude-analytical-maths-nbe-template-15",
      "variable_mark_per_question": false,
      "show_answers": true,
      "comments_count": 0
    },
    {
      "url": "http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-16/",
      "id": 2395,
      "title": "Aptitude Analytical Maths (NBE Template)",
      "description": "",
      "course": "Uncategorized",
      "start_date": "2.23-08-02.27:25:22+05:30",
      "end_date": "2.29-08-01T17:25:22+05:30",
      "duration": "0:30:30",
      "number_of_questions": 20,
      "negative_marks": "0.00",
      "mark_per_question": "1.00",
      "template_type": 4,
      "allow_retake": true,
      "max_retakes": null,
      "enable_ranks": false,
      "rank_publishing_date": null,
      "attempts_url": "http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-16/attempts/",
      "allow_pdf": true,
      "created": "2.25-04-09T00:00:00Z",
      "slug": "aptitude-analytical-maths-nbe-template-16",
      "variable_mark_per_question": false,
      "show_answers": true,
      "comments_count": 0
    }
  ]
}

This endpoint retrieves all available and unattempted exams for the authenticated user. This is same as getting all exams with state query parameter as available.

HTTP Request

GET /api/v2.2/exams/available/

Query Parameters

Parameter Type Description
course string Filters by course name. Ex: IBPS
q string Filters by exam title. Useful to search by exam title.

Get Upcoming Exams

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/exams/upcoming/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/exams/upcoming/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'cache-control': "no-cache",
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/exams/upcoming/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache'

The above command returns JSON structured like this:



{
  "count": 2,
  "next": null,
  "previous": null,
  "per_page": 20,
  "results": [
    {
      "url": "http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-15/",
      "id": 2394,
      "title": "Aptitude Analytical Maths (NBE Template)",
      "description": "",
      "course": "Uncategorized",
      "start_date": "2.23-08-02.27:25:22+05:30",
      "end_date": "2.29-08-01T17:25:22+05:30",
      "duration": "0:30:30",
      "number_of_questions": 20,
      "negative_marks": "0.00",
      "mark_per_question": "1.00",
      "template_type": 4,
      "allow_retake": true,
      "max_retakes": null,
      "enable_ranks": false,
      "rank_publishing_date": null,
      "attempts_url": "http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-15/attempts/",
      "allow_pdf": true,
      "created": "2.25-04-09T00:00:00Z",
      "slug": "aptitude-analytical-maths-nbe-template-15",
      "variable_mark_per_question": false,
      "show_answers": true,
      "comments_count": 0
    },
    {
      "url": "http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-16/",
      "id": 2395,
      "title": "Aptitude Analytical Maths (NBE Template)",
      "description": "",
      "course": "Uncategorized",
      "start_date": "2.23-08-02.27:25:22+05:30",
      "end_date": "2.29-08-01T17:25:22+05:30",
      "duration": "0:30:30",
      "number_of_questions": 20,
      "negative_marks": "0.00",
      "mark_per_question": "1.00",
      "template_type": 4,
      "allow_retake": true,
      "max_retakes": null,
      "enable_ranks": false,
      "rank_publishing_date": null,
      "attempts_url": "http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-16/attempts/",
      "allow_pdf": true,
      "created": "2.25-04-09T00:00:00Z",
      "slug": "aptitude-analytical-maths-nbe-template-16",
      "variable_mark_per_question": false,
      "show_answers": true,
      "comments_count": 0
    }
  ]
}

This endpoint retrieves all upcoming exams for the authenticated user. This is same as getting all exams with state query parameter as upcoming.

HTTP Request

GET /api/v2.2/exams/upcoming/

Query Parameters

Parameter Type Description
course string Filters by course name. Ex: IBPS
q string Filters by exam title. Useful to search by exam title.

Get History Exams

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/exams/history/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/exams/history/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'cache-control': "no-cache",
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/exams/history/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache'

The above command returns JSON structured like this:



{
  "count": 2,
  "next": null,
  "previous": null,
  "per_page": 20,
  "results": [
    {
      "url": "http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-15/",
      "id": 2394,
      "title": "Aptitude Analytical Maths (NBE Template)",
      "description": "",
      "course": "Uncategorized",
      "start_date": "2.23-08-02.27:25:22+05:30",
      "end_date": "2.29-08-01T17:25:22+05:30",
      "duration": "0:30:30",
      "number_of_questions": 20,
      "negative_marks": "0.00",
      "mark_per_question": "1.00",
      "template_type": 4,
      "allow_retake": true,
      "max_retakes": null,
      "enable_ranks": false,
      "rank_publishing_date": null,
      "attempts_url": "http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-15/attempts/",
      "allow_pdf": true,
      "created": "2.25-04-09T00:00:00Z",
      "slug": "aptitude-analytical-maths-nbe-template-15",
      "variable_mark_per_question": false,
      "show_answers": true,
      "comments_count": 0
    },
    {
      "url": "http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-16/",
      "id": 2395,
      "title": "Aptitude Analytical Maths (NBE Template)",
      "description": "",
      "course": "Uncategorized",
      "start_date": "2.23-08-02.27:25:22+05:30",
      "end_date": "2.29-08-01T17:25:22+05:30",
      "duration": "0:30:30",
      "number_of_questions": 20,
      "negative_marks": "0.00",
      "mark_per_question": "1.00",
      "template_type": 4,
      "allow_retake": true,
      "max_retakes": null,
      "enable_ranks": false,
      "rank_publishing_date": null,
      "attempts_url": "http://demo.testpress.in/api/v2.2/exams/aptitude-analytical-maths-nbe-template-16/attempts/",
      "allow_pdf": true,
      "created": "2.25-04-09T00:00:00Z",
      "slug": "aptitude-analytical-maths-nbe-template-16",
      "variable_mark_per_question": false,
      "show_answers": true,
      "comments_count": 0
    }
  ]
}

This endpoint retrieves all history exams for the authenticated user. This is same as getting all exams with state query parameter as history.

HTTP Request

GET /api/v2.2/exams/history/

Query Parameters

Parameter Type Description
course string Filters by course name. Ex: IBPS
q string Filters by exam title. Useful to search by exam title.

Attempts

Attempts API gives you access to read all the attempts which can be accessed by the authenticated user.

Get All Attempts

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/attempts/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/attempts/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'cache-control': "no-cache",
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/attempts/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache'

The above command returns JSON structured like this:

{
  "count": 2,
  "next": null,
  "previous": null,
  "per_page": 20,
  "results": [
    {
      "url": "http://demo.testpress.in/api/v2.2/attempts/125894/",
      "id": 125894,
      "exam": {
        "url": "http://demo.testpress.in/api/v2.2/exams/forum-ias-rbi-demo/",
        "id": 3720,
        "title": "FORUM IAS RBI DEMO",
        "description": "",
        "course": "TNPSC",
        "start_date": "2.25-11-07T12:37:11+05:30",
        "end_date": "2.25-11-15T12:37:11+05:30",
        "duration": "3:00:00",
        "number_of_questions": 200,
        "negative_marks": "0.00",
        "mark_per_question": "1.00",
        "template_type": 2,
        "allow_retake": true,
        "max_retakes": null,
        "enable_ranks": false,
        "rank_publishing_date": null,
        "allow_pdf": false,
        "created": "2.25-11-07T07:07:41.597Z",
        "slug": "forum-ias-rbi-demo",
        "variable_mark_per_question": false,
        "show_answers": true
      },
      "user": "testpress",
      "date": "2.25-11-07T07:12:49.873Z",
      "total_questions": 200,
      "score": "0.00",
      "review_url": "http://demo.testpress.in/api/v2.2/attempts/125894/review/",
      "questions_url": "http://demo.testpress.in/api/v2.2/attempts/125894/questions/",
      "percentile": 0,
      "correct_count": 0,
      "incorrect_count": 0,
      "last_started_time": "2.25-11-07T08:02:46.845Z",
      "remaining_time": "2.20:03",
      "time_taken": "0:49:57",
      "state": "Running",
      "rank": "NA",
      "max_rank": 0,
      "percentage": "0",
      "unanswered_count": 0,
      "commented_questions_count": 0,
      "comments_count": 0,
      "allow_retake": true,
      "remaining_attempts": null,
      "total_bonus": 0
    },
    {
      "url": "http://demo.testpress.in/api/v2.2/attempts/125872/",
      "id": 125872,
      "exam": {
        "url": "http://demo.testpress.in/api/v2.2/exams/aiims-exam/",
        "id": 3625,
        "title": "AIIMS Exam",
        "description": "",
        "course": "TNPSC",
        "start_date": "2.25-10-20T18:12:26+05:30",
        "end_date": null,
        "duration": "3:12:27",
        "number_of_questions": 200,
        "negative_marks": "0.00",
        "mark_per_question": "1.00",
        "template_type": 3,
        "allow_retake": true,
        "max_retakes": null,
        "enable_ranks": true,
        "rank_publishing_date": "2.25-10-20T12:42:44Z",
        "allow_pdf": false,
        "created": "2.25-10-20T12:43:01.684Z",
        "slug": "aiims-exam",
        "variable_mark_per_question": false,
        "show_answers": true
      },
      "user": "testpress",
      "date": "2.25-11-07T06:17:42.313Z",
      "total_questions": 200,
      "score": "0.00",
      "review_url": "http://demo.testpress.in/api/v2.2/attempts/125872/review/",
      "questions_url": "http://demo.testpress.in/api/v2.2/attempts/125872/questions/",
      "percentile": 60,
      "correct_count": 0,
      "incorrect_count": 0,
      "last_started_time": "2.25-11-07T06:17:42.375Z",
      "remaining_time": "3:12:26",
      "time_taken": "0:00:01",
      "state": "Completed",
      "rank": 4,
      "max_rank": 5,
      "percentage": "0",
      "unanswered_count": 200,
      "commented_questions_count": 0,
      "comments_count": 0,
      "allow_retake": true,
      "remaining_attempts": null,
      "total_bonus": 0
    }
  ]
}

This endpoint retrieves all attempts for the authenticated user.

HTTP Request

GET /api/v2.2/attempts/

Query Parameters

Parameter Type Description
course string Filters by course name. Ex: IBPS
q string Filters by exam title. Useful to search by exam title.

Get all attempts of an exam

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/exams/mathjax-sample-exam/attempts/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["cache-control"] = 'no-cache'

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

import requests

url = "http://demo.testpress.in/api/v2.2/exams/mathjax-sample-exam/attempts/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/exams/mathjax-sample-exam/attempts/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache'

The above command returns JSON structured like this:

{
  "count": 2,
  "next": null,
  "previous": null,
  "per_page": 20,
  "results": [
    {
      "url": "http://demo.testpress.in/api/v2.2/attempts/369/",
      "id": 369,
      "user": {
        "id": 5,
        "url": "http://demo.testpress.in/api/v2.2/users/5/",
        "username": "demouser",
        "display_name": "DemoUser is my name eeeeee123456789012345678901234",
        "first_name": "DemoUser is my name eeeeee123456789012345678901234",
        "last_name": "",
        "photo": "https://media.testpress.in/i/bc194c3b0f3241ad9473edf949de3cec.jpeg",
        "large_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/459b2af2355549dc8d7f411553128903.jpeg",
        "medium_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/05c3efc7e4e3454ebad1c32c0c69297c.jpeg",
        "medium_small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/ca7ae15e26cc4586ae5f98750c2acc62.jpeg",
        "small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/33936fd431e14a9ab54d7e24e70bf301.jpeg",
        "x_small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/673ceb6e18b343318fba39279ef07594.jpeg",
        "mini_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/3214f5359ad247d1b2e38609376af72b.jpeg"
      },
      "date": "2017-04-25T14:34:26.848Z",
      "total_questions": 25,
      "score": "0.00",
      "review_pdf_url": "",
      "review_url": "http://demo.testpress.in/api/v2.2/attempts/369/review/",
      "questions_url": "http://demo.testpress.in/api/v2.2/attempts/369/questions/",
      "percentile": 0,
      "correct_count": 0,
      "incorrect_count": 0,
      "last_started_time": "2017-05-11T12:26:08.889Z",
      "remaining_time": "1:09:31",
      "time_taken": "1:50:29",
      "state": "Running",
      "rank": 2,
      "max_rank": 165,
      "percentage": "0",
      "unanswered_count": 0,
      "rank_enabled": true,
      "sections": [],
      "speed": 0,
      "accuracy": 0
    },
    {
      "url": "http://demo.testpress.in/api/v2.2/attempts/12/",
      "id": 12,
      "user": {
        "id": 5,
        "url": "http://demo.testpress.in/api/v2.2/users/5/",
        "username": "demouser",
        "display_name": "DemoUser is my name eeeeee123456789012345678901234",
        "first_name": "DemoUser is my name eeeeee123456789012345678901234",
        "last_name": "",
        "photo": "https://media.testpress.in/i/bc194c3b0f3241ad9473edf949de3cec.jpeg",
        "large_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/459b2af2355549dc8d7f411553128903.jpeg",
        "medium_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/05c3efc7e4e3454ebad1c32c0c69297c.jpeg",
        "medium_small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/ca7ae15e26cc4586ae5f98750c2acc62.jpeg",
        "small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/33936fd431e14a9ab54d7e24e70bf301.jpeg",
        "x_small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/673ceb6e18b343318fba39279ef07594.jpeg",
        "mini_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/3214f5359ad247d1b2e38609376af72b.jpeg"
      },
      "date": "2017-01-24T06:33:09.230Z",
      "total_questions": 16,
      "score": "3.00",
      "review_pdf_url": "",
      "review_url": "http://demo.testpress.in/api/v2.2/attempts/12/review/",
      "questions_url": "http://demo.testpress.in/api/v2.2/attempts/12/questions/",
      "percentile": 83.64,
      "correct_count": 0,
      "incorrect_count": 0,
      "last_started_time": "2017-01-24T06:33:51.754Z",
      "remaining_time": "2:59:17",
      "time_taken": "0:00:43",
      "state": "Completed",
      "rank": 2,
      "max_rank": 165,
      "percentage": "12",
      "unanswered_count": 0,
      "rank_enabled": true,
      "sections": [],
      "speed": 847,
      "accuracy": 30
    }
  ]
}

This endpoint retrieves the attempts of a user for a particular exam.

HTTP Request

GET /api/v2.2/exams/<slug>/attempts/

URL Parameters

Parameter Description
slug The unique slug of the exam for which the attempts should be retrieved

Get a single attempt

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/attempts/125894/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/attempts/125894/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/attempts/125894/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache'

The above command returns JSON structured like this:

{
  "url": "http://demo.testpress.in/api/v2.2/attempts/125894/",
  "id": 125894,
  "exam": {
    "url": "http://demo.testpress.in/api/v2.2/exams/forum-ias-rbi-demo/",
    "id": 3720,
    "title": "FORUM IAS RBI DEMO",
    "description": "",
    "course": "TNPSC",
    "start_date": "2.25-11-07T12:37:11+05:30",
    "end_date": "2.25-11-15T12:37:11+05:30",
    "duration": "3:00:00",
    "number_of_questions": 200,
    "negative_marks": "0.00",
    "mark_per_question": "1.00",
    "template_type": 2,
    "allow_retake": true,
    "max_retakes": null,
    "enable_ranks": false,
    "rank_publishing_date": null,
    "allow_pdf": false,
    "created": "2.25-11-07T07:07:41.597Z",
    "slug": "forum-ias-rbi-demo",
    "variable_mark_per_question": false,
    "show_answers": true
  },
  "user": "testpress",
  "date": "2.25-11-07T07:12:49.873Z",
  "total_questions": 200,
  "score": "0.00",
  "review_url": "http://demo.testpress.in/api/v2.2/attempts/125894/review/",
  "questions_url": "http://demo.testpress.in/api/v2.2/attempts/125894/questions/",
  "percentile": 0,
  "correct_count": 0,
  "incorrect_count": 0,
  "last_started_time": "2.25-11-07T08:02:46.845Z",
  "remaining_time": "2.20:03",
  "time_taken": "0:49:57",
  "state": "Running",
  "rank": "NA",
  "max_rank": 0,
  "percentage": "0",
  "unanswered_count": 0,
  "commented_questions_count": 0,
  "comments_count": 0,
  "total_bonus": 0
}

This endpoint retrieves a single attempt.

HTTP Request

GET /api/v2.2/attempts/<id>

URL Parameters

Parameter Description
id The unique id of the attempt to retrieve

Create an attempt

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/exams/dummy-test-7-8/attempts/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/exams/dummy-test-7-8/attempts/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request POST \
  --url http://demo.testpress.in/api/v2.2/exams/dummy-test-7-8/attempts/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache'

The above command returns JSON structured like this:

{
  "url": "http://demo.testpress.in/api/v2.2/attempts/400/",
  "id": 400,
  "exam_url": "http://demo.testpress.in/api/v2.2/exams/dummy-test-7-8/",
  "user": {
    "id": 5,
    "url": "http://demo.testpress.in/api/v2.2/users/5/",
    "username": "demouser",
    "display_name": "DemoUser is my name eeeeee123456789012345678901234",
    "first_name": "DemoUser is my name eeeeee123456789012345678901234",
    "last_name": "",
    "photo": "https://media.testpress.in/i/bc194c3b0f3241ad9473edf949de3cec.jpeg",
    "large_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/459b2af2355549dc8d7f411553128903.jpeg",
    "medium_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/05c3efc7e4e3454ebad1c32c0c69297c.jpeg",
    "medium_small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/ca7ae15e26cc4586ae5f98750c2acc62.jpeg",
    "small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/33936fd431e14a9ab54d7e24e70bf301.jpeg",
    "x_small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/673ceb6e18b343318fba39279ef07594.jpeg",
    "mini_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/3214f5359ad247d1b2e38609376af72b.jpeg"
  },
  "date": "2017-05-24T07:32:09.891Z",
  "total_questions": 50,
  "score": 0,
  "review_pdf_url": "",
  "review_url": "http://demo.testpress.in/api/v2.2/attempts/400/review/",
  "questions_url": "http://demo.testpress.in/api/v2.2/attempts/400/questions/",
  "percentile": 0,
  "correct_count": 0,
  "incorrect_count": 0,
  "last_started_time": "2017-05-24T07:32:09.921Z",
  "remaining_time": "1:59:59",
  "time_taken": "0:00:01",
  "state": "Running",
  "rank": "NA",
  "max_rank": "NA",
  "percentage": "0",
  "unanswered_count": 0,
  "commented_questions_count": 0,
  "comments_count": 0,
  "total_bonus": 0,
  "rank_enabled": false,
  "exam": {
    "url": "http://demo.testpress.in/api/v2.2/exams/dummy-test-7-8/",
    "id": 31,
    "title": "Dummy Test 7",
    "description": "",
    "start_date": "2017-03-30T18:58:53+07:00",
    "end_date": null,
    "duration": "2:00:00",
    "number_of_questions": 50,
    "negative_marks": "0.00",
    "mark_per_question": "1.00",
    "template_type": 1,
    "allow_retake": true,
    "max_retakes": -1,
    "enable_ranks": false,
    "rank_publishing_date": null,
    "allow_pdf": false,
    "allow_question_pdf": false,
    "created": "2017-03-30T13:29:05.007Z",
    "slug": "dummy-test-7-8",
    "variable_mark_per_question": false,
    "show_answers": true,
    "allow_preemptive_section_ending": false,
    "sections": [
      {
        "order": 0,
        "name": "",
        "duration": "2:00:00",
        "cut_off": 0
      }
    ],
    "immediate_feedback": false,
    "categories": []
  },
  "sections": [],
  "speed": 0,
  "accuracy": 0,
  "institute_attempt_id": null
}

This endpoint will create a new attempt for the exam.

HTTP Request

POST /api/v2.2/exams/<exam_slug>/attempts/

URL Parameters

Parameter Description
exam_slug The unique slug of the exam for which the attempt should be created

Resume an attempt

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/attempts/125894/start/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Put.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/attempts/125894/start/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request PUT \
  --url http://demo.testpress.in/api/v2.2/attempts/125894/start/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache'

The above command returns JSON structured like this:

{
  "url": "http://demo.testpress.in/api/v2.2/attempts/125894/",
  "id": 125894,
  "exam": {
    "url": "http://demo.testpress.in/api/v2.2/exams/forum-ias-rbi-demo/",
    "id": 3720,
    "title": "FORUM IAS RBI DEMO",
    "description": "",
    "course": "TNPSC",
    "start_date": "2.25-11-07T12:37:11+05:30",
    "end_date": "2.25-11-15T12:37:11+05:30",
    "duration": "3:00:00",
    "number_of_questions": 200,
    "negative_marks": "0.00",
    "mark_per_question": "1.00",
    "template_type": 2,
    "allow_retake": true,
    "max_retakes": null,
    "enable_ranks": false,
    "rank_publishing_date": null,
    "allow_pdf": false,
    "created": "2.25-11-07T07:07:41.597Z",
    "slug": "forum-ias-rbi-demo",
    "variable_mark_per_question": false,
    "show_answers": true
  },
  "user": "testpress",
  "date": "2.25-11-07T07:12:49.873Z",
  "total_questions": 200,
  "score": "0.00",
  "review_url": "http://demo.testpress.in/api/v2.2/attempts/125894/review/",
  "questions_url": "http://demo.testpress.in/api/v2.2/attempts/125894/questions/",
  "percentile": 0,
  "correct_count": 0,
  "incorrect_count": 0,
  "last_started_time": "2.25-11-18T09:50:20.287Z",
  "remaining_time": "2.20:03",
  "time_taken": "0:49:57",
  "state": "Running",
  "rank": "NA",
  "max_rank": 0,
  "percentage": "0",
  "unanswered_count": 0,
  "commented_questions_count": 0,
  "comments_count": 0,
  "total_bonus": 0
}

This endpoint starts a paused attempt. This is for restarting the timer calculation incase of a paused attempt.

HTTP Request

PUT /api/v2.2/attempts/<id>/start/

URL Parameters

Parameter Description
id The unique id of the attempt to retrieve

Send heart beat

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/attempts/400/heartbeat/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Put.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/attempts/400/heartbeat/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request PUT \
  --url http://demo.testpress.in/api/v2.2/attempts/400/heartbeat/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache'

The above command returns JSON structured like this:

{
  "url": "http://demo.testpress.in/api/v2.2/attempts/400/",
  "id": 400,
  "exam_url": "http://demo.testpress.in/api/v2.2/exams/dummy-test-7-8/",
  "user": {
    "id": 5,
    "url": "http://demo.testpress.in/api/v2.2/users/5/",
    "username": "demouser",
    "display_name": "DemoUser is my name eeeeee123456789012345678901234",
    "first_name": "DemoUser is my name eeeeee123456789012345678901234",
    "last_name": "",
    "photo": "https://media.testpress.in/i/bc194c3b0f3241ad9473edf949de3cec.jpeg",
    "large_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/459b2af2355549dc8d7f411553128903.jpeg",
    "medium_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/05c3efc7e4e3454ebad1c32c0c69297c.jpeg",
    "medium_small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/ca7ae15e26cc4586ae5f98750c2acc62.jpeg",
    "small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/33936fd431e14a9ab54d7e24e70bf301.jpeg",
    "x_small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/673ceb6e18b343318fba39279ef07594.jpeg",
    "mini_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/3214f5359ad247d1b2e38609376af72b.jpeg"
  },
  "date": "2017-05-24T07:32:09.891Z",
  "total_questions": 50,
  "score": "0.00",
  "review_pdf_url": "",
  "review_url": "http://demo.testpress.in/api/v2.2/attempts/400/review/",
  "questions_url": "http://demo.testpress.in/api/v2.2/attempts/400/questions/",
  "percentile": 0,
  "correct_count": 0,
  "incorrect_count": 0,
  "last_started_time": "2017-05-24T07:37:10.655Z",
  "remaining_time": "1:54:59",
  "time_taken": "0:05:01",
  "state": "Running",
  "rank": "NA",
  "max_rank": "NA",
  "percentage": "0",
  "unanswered_count": 0,
  "commented_questions_count": 0,
  "comments_count": 0,
  "total_bonus": 0,
  "rank_enabled": false,
  "exam": {
    "url": "http://demo.testpress.in/api/v2.2/exams/dummy-test-7-8/",
    "id": 31,
    "title": "Dummy Test 7",
    "description": "",
    "start_date": "2017-03-30T18:58:53+07:00",
    "end_date": null,
    "duration": "2:00:00",
    "number_of_questions": 50,
    "negative_marks": "0.00",
    "mark_per_question": "1.00",
    "template_type": 1,
    "allow_retake": true,
    "max_retakes": -1,
    "enable_ranks": false,
    "rank_publishing_date": null,
    "allow_pdf": false,
    "allow_question_pdf": false,
    "created": "2017-03-30T13:29:05.007Z",
    "slug": "dummy-test-7-8",
    "variable_mark_per_question": false,
    "show_answers": true,
    "allow_preemptive_section_ending": false,
    "sections": [
      {
        "order": 0,
        "name": "",
        "duration": "2:00:00",
        "cut_off": 0
      }
    ],
    "immediate_feedback": false,
    "categories": []
  },
  "sections": [],
  "speed": 0,
  "accuracy": 0,
  "institute_attempt_id": null
}

For every minute, this API should be called during the attempt window. This is done to update the remaining time for that attempt in the server.

HTTP Request

PUT /api/v2.2/attempts/<id>/heartbeat/

URL Parameters

Parameter Description
id The unique id of the attempt to update

End an attempt

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/attempts/125894/end/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Put.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/attempts/125894/end/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request PUT \
  --url http://demo.testpress.in/api/v2.2/attempts/125894/end/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache'

The above command returns JSON structured like this:

{
  "url": "http://demo.testpress.in/api/v2.2/attempts/125894/",
  "id": 125894,
  "exam": {
    "url": "http://demo.testpress.in/api/v2.2/exams/forum-ias-rbi-demo/",
    "id": 3720,
    "title": "FORUM IAS RBI DEMO",
    "description": "",
    "course": "TNPSC",
    "start_date": "2.25-11-07T12:37:11+05:30",
    "end_date": "2.25-11-15T12:37:11+05:30",
    "duration": "3:00:00",
    "number_of_questions": 200,
    "negative_marks": "0.00",
    "mark_per_question": "1.00",
    "template_type": 2,
    "allow_retake": true,
    "max_retakes": null,
    "enable_ranks": false,
    "rank_publishing_date": null,
    "allow_pdf": false,
    "created": "2.25-11-07T07:07:41.597Z",
    "slug": "forum-ias-rbi-demo",
    "variable_mark_per_question": false,
    "show_answers": true
  },
  "user": "testpress",
  "date": "2.25-11-07T07:12:49.873Z",
  "total_questions": 200,
  "score": "2.00",
  "review_url": "http://demo.testpress.in/api/v2.2/attempts/125894/review/",
  "questions_url": "http://demo.testpress.in/api/v2.2/attempts/125894/questions/",
  "percentile": 100,
  "correct_count": 2,
  "incorrect_count": 6,
  "last_started_time": "2.25-11-18T09:50:20.287Z",
  "remaining_time": "2.20:03",
  "time_taken": "0:49:57",
  "state": "Completed",
  "rank": "NA",
  "max_rank": 0,
  "percentage": "1",
  "unanswered_count": 192,
  "commented_questions_count": 0,
  "comments_count": 0,
  "total_bonus": 0
}

This endpoint ends an attempt. The state of the attempt will return as Completed. An attempt which has been ended cannot be started again using the /start/ end point.

HTTP Request

PUT /api/v2.2/attempts/<id>/end/

URL Parameters

Parameter Description
id The unique id of the attempt to end

Get attempt questions

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/attempts/122046/questions/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/attempts/122046/questions/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/attempts/122046/questions/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache'

The above command returns JSON structured like this:

{
  "count": 100,
  "next": "http://demo.testpress.in/api/v2.2/attempts/122046/questions/?page=2",
  "previous": null,
  "per_page": 20,
  "results": [
    {
      "id": 12705318,
      "url": "http://demo.testpress.in/api/v2.2/attempts/122046/questions/12705318/",
      "question": {
        "question_html": "<p>Which of the following is/are the principal feature (s) of the Government of India Act, 1919? <br>\n1. Introduction of dyarchy in the executive government of the provinces<br>\n2. Introduction of separate communal electorates for Muslims<br>\n3. Devolution of legislative authority by the centre to the provinces</p><p>Select the correct answer using the codes given below:</p><p><img src=\"https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/ebd87eb5c09b445d879610586fca072e.png\"></p>",
        "direction": null,
        "answers": [
          {
            "text_html": "<p>1 only</p>",
            "id": 129
          },
          {
            "text_html": "<p>2 and 3 only</p>",
            "id": 130
          },
          {
            "text_html": "<p>1 and 3 only</p>",
            "id": 131
          },
          {
            "text_html": "<p>1, 2 and 3</p>",
            "id": 132
          }
        ],
        "essay_topics": [],
        "subject": "khecha subject",
        "type": "C"
      },
      "duration": null,
      "selected_answers": [],
      "essay_text": null,
      "essay_topic": null,
      "review": null
    },
    {
      "id": 12705296,
      "url": "http://demo.testpress.in/api/v2.2/attempts/122046/questions/12705296/",
      "question": {
        "question_html": "<p>With reference to National Rural Health Mission, which of the following are the jobs of ASHA, a trained community health worker?</p>\n<p>1.Accompanying women to the health facility for antenatal care checkup</p>\n<p>2.Using pregnancy test kits for early detection of pregnancy </p>\n<p>3.Providing information on nutrition and immunization</p>\n<p>4.Conducting the delivery of baby</p>\n<p>Select the correct answer using the codes given below:</p>",
        "direction": null,
        "answers": [
          {
            "text_html": "<p>1, 2 and 3 Only</p>",
            "id": 413
          },
          {
            "text_html": "<p>2 and 4 Only</p>",
            "id": 414
          },
          {
            "text_html": "<p>1 and 3 Only</p>",
            "id": 415
          },
          {
            "text_html": "<p>1, 2, 3 and 4</p>",
            "id": 416
          }
        ],
        "essay_topics": [],
        "subject": "Sin Questions",
        "type": "R"
      },
      "duration": null,
      "selected_answers": [],
      "essay_text": null,
      "essay_topic": null,
      "review": null
    }
  ]
}

This endpoint returns all questions for an attempt.

HTTP Request

PUT /api/v2.2/attempts/<id>/questions/

URL Parameters

Parameter Description
id The unique id of the attempt to retrieve

Update attempt questions

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/attempts/122046/questions/12705318/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Put.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request.body = "{\n\"selected_answers\": [129, 130],\n\"review\": true\n}"

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

url = "http://demo.testpress.in/api/v2.2/attempts/122046/questions/12705318/"

payload = "{\n\"selected_answers\": [129, 130],\n\"review\": true\n}"
headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'content-type': "application/json",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request PUT \
  --url http://demo.testpress.in/api/v2.2/attempts/122046/questions/12705318/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
  --data '{\n"selected_answers": [129, 130],\n"review": true\n}'

The above command returns JSON structured like this:

{
  "id": 12705318,
  "url": "http://demo.testpress.in/api/v2.2/attempts/122046/questions/12705318/",
  "question": {
    "question_html": "<p>Which of the following is/are the principal feature (s) of the Government of India Act, 1919? <br>\n1. Introduction of dyarchy in the executive government of the provinces<br>\n2. Introduction of separate communal electorates for Muslims<br>\n3. Devolution of legislative authority by the centre to the provinces</p><p>Select the correct answer using the codes given below:</p><p><img src=\"https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/ebd87eb5c09b445d879610586fca072e.png\"></p>",
    "direction": null,
    "answers": [
      {
        "text_html": "<p>1 only</p>",
        "id": 129
      },
      {
        "text_html": "<p>2 and 3 only</p>",
        "id": 130
      },
      {
        "text_html": "<p>1 and 3 only</p>",
        "id": 131
      },
      {
        "text_html": "<p>1, 2 and 3</p>",
        "id": 132
      }
    ],
    "essay_topics": [],
    "subject": "khecha subject",
    "type": "C"
  },
  "duration": "20 days, 3:58:48.044696",
  "selected_answers": [
    129,
    130
  ],
  "essay_text": null,
  "essay_topic": null,
  "review": true
}

This endpoint will update a question with the selected_answers and review.

HTTP Request

PUT /api/v2.2/attempts/<id>/questions/<question_id>

URL Parameters

Parameter Description
id The unique id of the attempt
question_id The unique id of the attempt question

Review attempt questions

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/attempts/122046/review/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/attempts/122046/review/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/attempts/122046/review/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache'

The above command returns JSON structured like this:

{
  "count": 2,
  "next": null,
  "previous": null,
  "per_page": 20,
  "results": [
    {
      "id": 52,
      "url": "http://demo.testpress.in/api/v2.2/attempts/12/review/52/",
      "order": 0,
      "question": {
        "id": 2,
        "url": "http://demo.testpress.in/api/v2.2/questions/2/",
        "question_html": "<p>Pick similar things</p>\n",
        "direction": null,
        "answers": [
          {
            "id": 3,
            "text_html": "<p>ComputerComputer</p>\n",
            "is_correct": true
          },
          {
            "id": 4,
            "text_html": "<p>Mouse Mouse Mouse</p>\n",
            "is_correct": true
          },
          {
            "id": 5,
            "text_html": "<p>Table</p>\n",
            "is_correct": false
          },
          {
            "id": 6,
            "text_html": "<p>CPU</p>\n",
            "is_correct": true
          }
        ],
        "essay_topics": [],
        "subject": "General Knowledge",
        "explanation_html": "",
        "type": "C",
        "comments_url": "http://demo.testpress.in/api/v2.2/questions/2/comments/",
        "marks": "1.00",
        "negative_marks": "0.00"
      },
      "duration": "NA",
      "best_duration": 0.61,
      "average_duration": 17.31,
      "selected_answers": [],
      "essay_text": null,
      "essay_topic": null,
      "review": null,
      "comments_count": 0,
      "correct_percentage": 25
    },
    {
      "id": 53,
      "url": "http://demo.testpress.in/api/v2.2/attempts/12/review/53/",
      "order": 0,
      "question": {
        "id": 3,
        "url": "http://demo.testpress.in/api/v2.2/questions/3/",
        "question_html": "<p>Odd one out</p>\n",
        "direction": null,
        "answers": [
          {
            "id": 7,
            "text_html": "<p>Table Table Table</p>\n",
            "is_correct": false
          },
          {
            "id": 8,
            "text_html": "<p>TreeTreeTree</p>\n",
            "is_correct": true
          },
          {
            "id": 9,
            "text_html": "<p>Book</p>\n",
            "is_correct": false
          },
          {
            "id": 10,
            "text_html": "<p>Water Bottle</p>\n",
            "is_correct": false
          }
        ],
        "essay_topics": [],
        "subject": "General Knowledge",
        "explanation_html": "",
        "type": "R",
        "comments_url": "http://demo.testpress.in/api/v2.2/questions/3/comments/",
        "marks": "1.00",
        "negative_marks": "0.00"
      },
      "duration": 1,
      "best_duration": 0.67,
      "average_duration": 11.3,
      "selected_answers": [
        8
      ],
      "essay_text": null,
      "essay_topic": null,
      "review": false,
      "comments_count": 0,
      "correct_percentage": 16
    }
  ]
}

This endpoint returns all questions for an attempt with correct answer & explanation.

HTTP Request

GET /api/v2.2/attempts/<id>/review/

URL Parameters

Parameter Description
id The unique id of the attempt for which the questions should be retrieved

Attempt subject wise analytics

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/attempts/377/review/subjects/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/attempts/377/review/subjects/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/attempts/377/review/subjects/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache'

The above command returns JSON structured like this:

{
  "count": 6,
  "next": null,
  "previous": null,
  "per_page": 200,
  "results": [
    {
      "id": 20,
      "name": "PSM",
      "total": 2,
      "correct": 0,
      "unanswered": 0,
      "incorrect": 2,
      "parent": null,
      "leaf": true,
      "score": "-2.00"
    },
    {
      "id": 17,
      "name": "Microbiology",
      "total": 1,
      "correct": 1,
      "unanswered": 0,
      "incorrect": 0,
      "parent": null,
      "leaf": true,
      "score": "4.00"
    }
  ]
}

This endpoint returns subject wise analytics of the attempt.

HTTP Request

GET /api/v2.2/attempts/<id>/review/subjects/

URL Parameters

Parameter Description
id The unique id of the attempt for which analytics should be retrieved

Products

Products API gives you access to read all the products which are active and can be purchased.

Get All Products

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/products/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/products/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/products/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache'
var client = new RestClient("http://demo.testpress.in/api/v2.2/products/");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw");
IRestResponse response = client.Execute(request);

The above command returns JSON structured like this:

{
  "count": 1,
  "next": null,
  "previous": null,
  "per_page": 20,
  "results": [
    {
      "id": 243,
      "url": "http://demo.testpress.in/api/v2.2/products/free-ias-prelims-power-pack/",
      "title": "Free IAS Prelims Power Pack",
      "slug": "free-ias-prelims-power-pack",
      "image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/770056a05ab2433191eeeef8de75210f.png",
      "images": [
        {
          "original": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/770056a05ab2433191eeeef8de75210f.png",
          "medium": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/bfbfcf2f31f84c5aada30eba2ae6bd2e.png",
          "small": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/63b181a83d8c4e198309cacb110bac35.png"
        }
      ],
      "start_date": "2.25-01-01T00:00:00+05:30",
      "end_date": "2021-12-31T00:00:00+05:30",
      "categories": [
        "TNPSC"
      ],
      "types": [
        "E-books",
        "Exams"
      ],
      "exams_count": 1,
      "notes_count": 0,
      "price": "1.00"
    }
  ]
}

This endpoint retrieves all products available for purchase in an institute.

HTTP Request

GET /api/v2.2/products/

Query Parameters

Parameter Type Description
category string Filters by category name. Ex: IBPS

Fields

Name Type Description
id int The product unique ID
url string URL to get details of the product
title string Title of the product
slug string Human readable keyword string of the product
images array An array of image urls for the product
  • original - User uploaded size
  • medium - 300x250px
  • small - 100x83px
start_date datestring Start date of product
end_date datestring End date of product
categories array Categories to which this product belongs
types array Type of goods included in this package. Can be E-books, Exams, Classroom Program, Books
price string Price of the product in INR
exams_count int Number of exams present in this product
notes_count int Number of documents present in this product

Get a single product

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/products/free-ias-prelims-power-pack/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/products/free-ias-prelims-power-pack/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/products/free-ias-prelims-power-pack/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache'
var client = new RestClient("http://demo.testpress.in/api/v2.2/products/free-ias-prelims-power-pack/");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw");
IRestResponse response = client.Execute(request);

The above command returns JSON structured like this:

{
  "count": 1,
  "next": null,
  "previous": null,
  "per_page": 20,
  "results": [
    {
      "id": 243,
      "url": "http://demo.testpress.in/api/v2.2/products/free-ias-prelims-power-pack/",
      "title": "Free IAS Prelims Power Pack",
      "slug": "free-ias-prelims-power-pack",
      "image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/770056a05ab2433191eeeef8de75210f.png",
      "images": [
        {
          "original": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/770056a05ab2433191eeeef8de75210f.png",
          "medium": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/bfbfcf2f31f84c5aada30eba2ae6bd2e.png",
          "small": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/63b181a83d8c4e198309cacb110bac35.png"
        }
      ],
      "start_date": "2.25-01-01T00:00:00+05:30",
      "end_date": "2021-12-31T00:00:00+05:30",
      "categories": [
        "TNPSC"
      ],
      "types": [
        "E-books",
        "Exams"
      ],
      "exams_count": 1,
      "notes_count": 0,
      "price": "1.00"
    }
  ]
}

This endpoint retrieves all products available for purchase in an institute.

HTTP Request

GET /api/v2.2/products/<slug>

URL Parameters

Parameter Description
slug The unique slug of the product to retrieve

Fields

Name Type Description
description string Brief description of the product
exams array Exams present in this product
notes array Documents present in this product
requires_shipping boolean Whether the product has shippable goods

Posts

Posts are broadcast data which the institutes want to share to their users. This endpoint can be used to retrieve the posts which are accessible to a particular user.

Get all posts

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/posts/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/posts/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'content-type': "application/json",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/posts/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json'
var client = new RestClient("http://demo.testpress.in/api/v2.2/posts/");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw");
IRestResponse response = client.Execute(request);

The above command returns JSON structured like this:

{
  "count": 2,
  "next": "http://demo.testpress.in/api/v2.2/posts/?page=2",
  "previous": null,
  "per_page": 20,
  "results": [
    {
      "url": "http://demo.testpress.in/api/v2.2/posts/post-title2/",
      "created_by": {
        "id": 10,
        "url": "http://demo.testpress.in/api/v2.2/users/10/",
        "username": "admin",
        "display_name": "admin",
        "first_name": "",
        "last_name": "",
        "photo": "",
        "large_image": "",
        "medium_image": "",
        "small_image": "",
        "x_small_image": "",
        "mini_image": ""
      },
      "category": {
        "id": 2,
        "name": "Daliy News",
        "color": "33CC33",
        "slug": "daliy-news"
      },
      "created": "2.25-10-15T15:24:34Z",
      "modified": "2.25-10-15T15:24:34Z",
      "id": 33,
      "active": true,
      "title": "Post Title2",
      "summary": "summary goes here",
      "institute": 1
    },
    {
      "url": "http://demo.testpress.in/api/v2.2/posts/working-great/",
      "created_by": {
        "id": 10,
        "url": "http://demo.testpress.in/api/v2.2/users/10/",
        "username": "admin",
        "display_name": "admin",
        "first_name": "",
        "last_name": "",
        "photo": "",
        "large_image": "",
        "medium_image": "",
        "small_image": "",
        "x_small_image": "",
        "mini_image": ""
      },
      "category": {
        "id": 2,
        "name": "Daliy News",
        "color": "33CC33",
        "slug": "daliy-news"
      },
      "created": "2.25-10-07T06:00:07Z",
      "modified": "2.25-10-07T06:00:07Z",
      "id": 26,
      "active": true,
      "title": "Working Great",
      "summary": "All is Well",
      "institute": 1
    }
  ]
}

This endpoint retrieves all posts for the authenticated user.

HTTP Request

GET /api/v2.2/posts/

Query Parameters

Parameter Type Description
gt datestring Filter posts created greater than the date
lt datestring Filter posts created lesser than the date
order string Order posts based on the field queried. For descending order, prefix with ’-’
category string Filter posts based on category

Get single post

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/posts/working-great/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/posts/working-great/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'content-type': "application/json",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/posts/working-great/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json'
var client = new RestClient("http://demo.testpress.in/api/v2.2/posts/working-great/");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw");
IRestResponse response = client.Execute(request);

The above command returns JSON structured like this:

{
  "url": "http://demo.testpress.in/api/v2.2/posts/working-great/",
  "created_by": {
    "id": 10,
    "url": "http://demo.testpress.in/api/v2.2/users/10/",
    "username": "admin",
    "display_name": "admin",
    "first_name": "",
    "last_name": "",
    "photo": "",
    "large_image": "",
    "medium_image": "",
    "small_image": "",
    "x_small_image": "",
    "mini_image": ""
  },
  "category": {
    "id": 2,
    "name": "Daliy News",
    "color": "33CC33",
    "slug": "daliy-news"
  },
  "created": "2.25-10-07T06:00:07Z",
  "modified": "2.25-10-07T06:00:07Z",
  "id": 26,
  "active": true,
  "title": "Working Great",
  "summary": "All is Well",
  "content_html": "<p>Good Better Best</p>",
  "institute": 1
}

This endpoint retrieves a single post.

HTTP Request

GET /api/v2.2/posts/<slug>

URL Parameters

Parameter Description
slug The unique slug of the post to retrieve

Basic Example

Following is a basic example of test taking flow

  1. Get the Auth token to authenticate the user using the Get Auth Token API.
  2. Use the token as Authorization header in the following requests.
  3. Now try to get list of exams using the Get Available Exams API.
  4. Get exam details of an exam in the list of exams using the Get Exam Details API.
  5. Start a new attempt for the exam using the Create an attempt API.
  6. Using the response of the new attempt, get the questions for that attempt using the Get attempt questions API.
  7. Attend the questions by updating the selected answers or review later flag using Update attempt questions API.
  8. Send heart beat every 1 minute using Send Heart Beat API.
  9. End the attempt once all the required questions have been attempted.
  10. Review the solutions of the completed attempt using Get Review Questions API.
  11. Review the subject wise analytics of the completed attempt using Get Attempt Subject Wise Analytics API.

To retake the attempt

  1. Get list of attempted exams using the Get History Exams API.
  2. Get the attempts of an exam in the history exams list using Get Attempts of an Exam API.
  3. Perform the above steps 4 to 11

Admin APIs

Admin APIs provides access to all operations which can be done by a admin.

Users

Admin Users API gives you access to create/edit users in the institute.

Create User

curl --request POST \
  --url http://demo.testpress.in/api/v2.2/admin/users/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
  --data '{"username": "lorem", "password": "ipsum1$", "first_name": "John", "last_name": "Appleseed", "email": "test@example.com", "birth_date": "03/07/2016", "gender_code": "male", "state_code": "IN-TN", "batches": ["Test Batch", "UPSC Morning Batch"]}'
require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/admin/users/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84'
request["cache-control"] = 'no-cache'
request.body = "{\n    \"username\": \"lorem\",\n    \"password\": \"ipsum1$\",\n    \"first_name\": \"John\",\n    \"last_name\": \"Appleseed\",\n    \"email\": \"test@example.com\",\n    \"birth_date\": \"03/07/2016\",\n    \"gender_code\": \"male\",\n    \"state_code\": \"IN-TN\",\n    \"batches\": [\"Test Batch\", \"UPSC Morning Batch\"]\n}"

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

url = "http://demo.testpress.in/api/v2.2/admin/users/"

payload = "{\n    \"username\": \"lorem\",\n    \"password\": \"ipsum1$\",\n    \"first_name\": \"John\",\n    \"last_name\": \"Appleseed\",\n    \"email\": \"test@example.com\",\n    \"birth_date\": \"03/07/2016\",\n    \"gender_code\": \"male\",\n    \"state_code\": \"IN-TN\",\n    \"batches\": [\"Test Batch\", \"UPSC Morning Batch\"]\n}"
headers = {
    'content-type': "application/json",
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84",
    'cache-control': "no-cache"
    }

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

print(response.text)
var client = new RestClient("http://demo.testpress.in/api/v2.2/admin/users/");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n    \"username\": \"lorem\",\n    \"password\": \"ipsum1$\",\n    \"first_name\": \"John\",\n    \"last_name\": \"Appleseed\",\n    \"email\": \"test@example.com\",\n    \"birth_date\": \"03/07/2016\",\n    \"gender_code\": \"male\",\n    \"state_code\": \"IN-TN\",\n    \"batches\": [\"Test Batch\", \"UPSC Morning Batch\"]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
<?php

$request = new HttpRequest();
$request->setUrl('http://demo.testpress.in/api/v2.2/admin/users/');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'cache-control' => 'no-cache',
  'authorization' => 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84',
  'content-type' => 'application/json'
));

$request->setBody('{
    "username": "lorem",
    "password": "ipsum1$",
    "first_name": "John",
    "last_name": "Appleseed",
    "email": "test@example.com",
    "birth_date": "03/07/2016",
    "gender_code": "male",
    "state_code": "IN-TN",
    "batches": ["Test Batch", "UPSC Morning Batch"]
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"username\": \"lorem\",\n    \"password\": \"ipsum1$\",\n    \"first_name\": \"John\",\n    \"last_name\": \"Appleseed\",\n    \"email\": \"test@example.com\",\n    \"birth_date\": \"03/07/2016\",\n    \"gender_code\": \"male\",\n    \"state_code\": \"IN-TN\",\n    \"batches\": [\"Test Batch\", \"UPSC Morning Batch\"]\n}");
Request request = new Request.Builder()
  .url("http://demo.testpress.in/api/v2.2/admin/users/")
  .post(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();
var http = require("http");

var options = {
  "method": "POST",
  "hostname": "demo.testpress.in",
  "port": null,
  "path": "/api/v2.2/admin/users/",
  "headers": {
    "content-type": "application/json",
    "authorization": "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84",
    "cache-control": "no-cache"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ username: 'lorem',
  password: 'ipsum1$',
  first_name: 'John',
  last_name: 'Appleseed',
  email: 'test@example.com',
  birth_date: '03/07/2016',
  gender_code: 'male',
  state_code: 'IN-TN',
  batches: [ 'Test Batch', 'UPSC Morning Batch' ] }));
req.end();
package main

import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "http://demo.testpress.in/api/v2.2/admin/users/"

    payload := strings.NewReader("{\n    \"username\": \"lorem\",\n    \"password\": \"ipsum1$\",\n    \"first_name\": \"John\",\n    \"last_name\": \"Appleseed\",\n    \"email\": \"test@example.com\",\n    \"birth_date\": \"03/07/2016\",\n    \"gender_code\": \"male\",\n    \"state_code\": \"IN-TN\",\n    \"batches\": [\"Test Batch\", \"UPSC Morning Batch\"]\n}")

    req, _ := http.NewRequest("POST", url, payload)

    req.Header.Add("content-type", "application/json")
    req.Header.Add("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84")
    req.Header.Add("cache-control", "no-cache")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}

The above command returns JSON structured like this:

{
  "id": 1892,
  "url": "http://demo.testpress.in/api/v2.2/admin/users/1892/",
  "username": "lorem",
  "first_name": "John",
  "last_name": "Appleseed",
  "display_name": "John Appleseed",
  "email": "test@example.com",
  "photo": null,
  "large_image": "",
  "medium_image": "",
  "small_image": "",
  "x_small_image": "",
  "mini_image": "",
  "birth_date": "03/07/2016",
  "gender_code": "male",
  "gender": "Male",
  "address1": "",
  "address2": "",
  "city": "",
  "zip": "",
  "state": "Tamil Nadu",
  "state_code": "IN-TN",
  "phone": "",
  "batches": [
    {
      "id": 29,
      "name": "Test Batch",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/29/"
    },
    {
      "id": 23,
      "name": "UPSC Morning Batch",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/23/"
    }
  ],
  "batches_url": "http://demo.testpress.in/api/v2.2/admin/users/1892/batches/"
}

This endpoint creates a user.

HTTP Request

POST /api/v2.2/admin/users/

Except username and password, all other fields are optional.

Fields

Name Type Description
username string Username of the user
first_name string First name of the user
last_name string Last name of the user
email string Email of the user
birth_date datestring Birth date of user. Should be in DD/MM/YYYY format
gender_code string Gender of user. Can be “male”, “female” or “trans”
address1 string Address of user
address2 string Address of user
city string City of user
zip string Pincode of user
state_code string State of user in ISO 3166-2:IN format (https://en.wikipedia.org/wiki/ISO_3166-2:IN)
phone string Phone of user
batches string Pass as array of batch name strings.

View User

package main

import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "http://demo.testpress.in/api/v2.2/admin/users/1889/"

    payload := strings.NewReader("{\n    \"username\": \"admin15\",\n    \"password\": \"demouser\",\n    \"first_name\": \"Cool\",\n    \"last_name\": \"dude\",\n    \"email\": \"cool@dude.com\",\n    \"birth_date\": \"03/07/2016\",\n    \"gender_code\": \"trans\",\n    \"state_code\": \"IN-TN\"\n}")

    req, _ := http.NewRequest("GET", url, payload)

    req.Header.Add("content-type", "application/json")
    req.Header.Add("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc")
    req.Header.Add("cache-control", "no-cache")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}
require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/admin/users/1889/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc'
request["cache-control"] = 'no-cache'
request.body = "{\n    \"username\": \"admin15\",\n    \"password\": \"demouser\",\n    \"first_name\": \"Cool\",\n    \"last_name\": \"dude\",\n    \"email\": \"cool@dude.com\",\n    \"birth_date\": \"03/07/2016\",\n    \"gender_code\": \"trans\",\n    \"state_code\": \"IN-TN\"\n}"

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

url = "http://demo.testpress.in/api/v2.2/admin/users/1889/"

payload = "{\n    \"username\": \"admin15\",\n    \"password\": \"demouser\",\n    \"first_name\": \"Cool\",\n    \"last_name\": \"dude\",\n    \"email\": \"cool@dude.com\",\n    \"birth_date\": \"03/07/2016\",\n    \"gender_code\": \"trans\",\n    \"state_code\": \"IN-TN\"\n}"
headers = {
    'content-type': "application/json",
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/admin/users/1889/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
  --data '{"username": "admin15", "password": "demouser", "first_name": "Cool", "last_name": "dude", "email": "cool@dude.com", "birth_date": "03/07/2016", "gender_code": "trans", "state_code": "IN-TN"\n}'
<?php

$request = new HttpRequest();
$request->setUrl('http://demo.testpress.in/api/v2.2/admin/users/1889/');
$request->setMethod(HTTP_METH_GET);

$request->setHeaders(array(
  'cache-control' => 'no-cache',
  'authorization' => 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc',
  'content-type' => 'application/json'
));

$request->setBody('{
    "username": "admin15",
    "password": "demouser",
    "first_name": "Cool",
    "last_name": "dude",
    "email": "cool@dude.com",
    "birth_date": "03/07/2016",
    "gender_code": "trans",
    "state_code": "IN-TN"
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
var client = new RestClient("http://demo.testpress.in/api/v2.2/admin/users/1889/");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n    \"username\": \"admin15\",\n    \"password\": \"demouser\",\n    \"first_name\": \"Cool\",\n    \"last_name\": \"dude\",\n    \"email\": \"cool@dude.com\",\n    \"birth_date\": \"03/07/2016\",\n    \"gender_code\": \"trans\",\n    \"state_code\": \"IN-TN\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
var http = require("http");

var options = {
  "method": "GET",
  "hostname": "demo.testpress.in",
  "port": null,
  "path": "/api/v2.2/admin/users/1889/",
  "headers": {
    "content-type": "application/json",
    "authorization": "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc",
    "cache-control": "no-cache"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ username: 'admin15',
  password: 'demouser',
  first_name: 'Cool',
  last_name: 'dude',
  email: 'cool@dude.com',
  birth_date: '03/07/2016',
  gender_code: 'trans',
  state_code: 'IN-TN' }));
req.end();
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"username\": \"admin15\",\n    \"password\": \"demouser\",\n    \"first_name\": \"Cool\",\n    \"last_name\": \"dude\",\n    \"email\": \"cool@dude.com\",\n    \"birth_date\": \"03/07/2016\",\n    \"gender_code\": \"trans\",\n    \"state_code\": \"IN-TN\"\n}");
Request request = new Request.Builder()
  .url("http://demo.testpress.in/api/v2.2/admin/users/1889/")
  .get()
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

The above command returns JSON structured like this:

{
  "id": 1889,
  "url": "http://demo.testpress.in/api/v2.2/admin/users/1889/",
  "username": "lorem",
  "first_name": "John",
  "last_name": "Appleseed",
  "display_name": "John Appleseed",
  "email": "test@example.com",
  "photo": null,
  "large_image": "",
  "medium_image": "",
  "small_image": "",
  "x_small_image": "",
  "mini_image": "",
  "birth_date": "03/07/2016",
  "gender_code": "male",
  "gender": "Male",
  "address1": "",
  "address2": "",
  "city": "",
  "zip": "",
  "state": "Tamil Nadu",
  "state_code": "IN-TN",
  "phone": ""
}

This endpoint allows you to view details of a particular user.

HTTP Request

GET /api/v2.2/admin/users/<:id>

URL Parameters

Parameter Description
id Unique Id of the user to retrieve

Fields

Name Type Description
username string Username of the user
first_name string First name of the user
last_name string Last name of the user
display_name string Name of the user to be displayed
email string Email of the user
photo string Original image of the user as uploaded
large_image string Profile image with size 256x256
medium_image string Profile image with size 128x128
small_image string Profile image with size 48x48
xsmall_image string Profile image with size 32x32
mini_image string Profile image with size 24x24
birth_date datestring Birth date of user. Should be in DD/MM/YYYY format
gender_code string Gender of user. Can be “male”, “female” or “trans”
gender string (Read only) Human readable gender of user. Can be “Male”, “Female” or “Transgender”
address1 string Address of user
address2 string Address of user
city string City of user
zip string Pincode of user
state_code string State of user in ISO 3166-2:IN format (https://en.wikipedia.org/wiki/ISO_3166-2:IN)
phone string Phone of user

Update User

package main

import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "http://demo.testpress.in/api/v2.3/admin/users/2120/"

    payload := strings.NewReader("{\n\t\"password\": \"welcome\"\n}")

    req, _ := http.NewRequest("PUT", url, payload)

    req.Header.Add("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc")
    req.Header.Add("content-type", "application/json")
    req.Header.Add("cache-control", "no-cache")
    req.Header.Add("postman-token", "9c29d96f-7ea6-35c9-1d30-8ccb20389d39")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}
require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.3/admin/users/2120/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Put.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc'
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request["postman-token"] = 'e395af73-374f-75e4-4ca2-3751f84b0598'
request.body = "{\n\t\"password\": \"welcome\"\n}"

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

url = "http://demo.testpress.in/api/v2.3/admin/users/2120/"

payload = "{\n\t\"password\": \"welcome\"\n}"
headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc",
    'content-type': "application/json",
    'cache-control': "no-cache",
    'postman-token': "25ef8298-0a61-7404-3a97-db9d0250ef78"
    }

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

print(response.text)
curl --request PUT \
  --url http://demo.testpress.in/api/v2.3/admin/users/2120/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
  --header 'postman-token: 5bdb17f6-db4d-c72e-a30f-c1776f0d8384' \
  --data '{\n   "password": "welcome"\n}'
<?php

$request = new HttpRequest();
$request->setUrl('http://demo.testpress.in/api/v2.3/admin/users/2120/');
$request->setMethod(HTTP_METH_PUT);

$request->setHeaders(array(
  'postman-token' => '652f45cc-e181-b3e2-706c-47459bb5363e',
  'cache-control' => 'no-cache',
  'content-type' => 'application/json',
  'authorization' => 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc'
));

$request->setBody('{
    "password": "welcome"
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
var client = new RestClient("http://demo.testpress.in/api/v2.3/admin/users/2120/");
var request = new RestRequest(Method.PUT);
request.AddHeader("postman-token", "0ce5b8e5-0793-457c-32e7-f5c96be55aa9");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc");
request.AddParameter("application/json", "{\n\t\"password\": \"welcome\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
var http = require("http");

var options = {
  "method": "PUT",
  "hostname": "demo.testpress.in",
  "port": null,
  "path": "/api/v2.3/admin/users/2120/",
  "headers": {
    "authorization": "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc",
    "content-type": "application/json",
    "cache-control": "no-cache",
    "postman-token": "a4f44159-0b97-e199-ecca-7c5646324c84"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ password: 'welcome' }));
req.end();
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"password\": \"welcome\"\n}");
Request request = new Request.Builder()
  .url("http://demo.testpress.in/api/v2.3/admin/users/2120/")
  .put(body)
  .addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc")
  .addHeader("content-type", "application/json")
  .addHeader("cache-control", "no-cache")
  .addHeader("postman-token", "2d5c843c-b6ee-d38e-7a3b-7a71c0353bc8")
  .build();

Response response = client.newCall(request).execute();

The above command returns JSON structured like this:

{
    "id": 2120,
    "username": "goodboy",
    "password_hash": "pbkdf2_sha256$12000$zaz1v370q51a$ipNrjQCWNOAmdFsHWPHHZ1i1+5hxF5LxHZ+VfFZ9mrM=",
    "email": "",
    "first_name": "",
    "last_name": "",
    "display_name": "goodboy",
    "photo": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/png/3a6be029faea4c41915291da8778c36d.png",
    "large_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/png/3a6be029faea4c41915291da8778c36d.png",
    "medium_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/png/82b59e4b2d29426ab74b25457384961b.png",
    "medium_small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/png/b8d2e490f8414d8485a1261fcba80d11.png",
    "small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/png/2aa6f66820dd4fe9acdd2b63da148f8c.png",
    "x_small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/png/64818b7216f340b3be636e32effc57fd.png",
    "mini_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/png/9746d9747c184aa98273fbb9c5222adc.png",
    "birth_date": null,
    "gender_code": null,
    "gender": null,
    "address1": "",
    "address2": "",
    "city": "",
    "zip": "",
    "state": "",
    "state_code": "",
    "phone": "",
    "batches": [],
    "created": "2017-08-03T18:25:45.949568Z",
    "modified": "2017-08-03T18:29:24.712464Z"
}

This endpoint allows you to update details of a particular user.

HTTP Request

PUT /api/v2.2/admin/users/<:id>

URL Parameters

Parameter Description
id Unique Id of the user to update

Fields

Name Type Description
username string Username of the user
password string Password to update the user
first_name string First name of the user
last_name string Last name of the user
display_name string Name of the user to be displayed
email string Email of the user
photo string Original image of the user as uploaded
large_image string Profile image with size 256x256
medium_image string Profile image with size 128x128
small_image string Profile image with size 48x48
xsmall_image string Profile image with size 32x32
mini_image string Profile image with size 24x24
birth_date datestring Birth date of user. Should be in DD/MM/YYYY format
gender_code string Gender of user. Can be “male”, “female” or “trans”
gender string (Read only) Human readable gender of user. Can be “Male”, “Female” or “Transgender”
address1 string Address of user
address2 string Address of user
city string City of user
zip string Pincode of user
state_code string State of user in ISO 3166-2:IN format (https://en.wikipedia.org/wiki/ISO_3166-2:IN)
state string State (Read Only)
phone string Phone of user

Read Only Fields

password_hash, gender, state, large_image, medium_image, medium_small_image, small_image, xsmall_image, mini_image, created, modified

Write Only Fields

password

Delete User

This endpoint allows you to delete particular user. Please be aware this will delete all the data related to the user. The operation is ir reversible

HTTP Request

DELETE /api/v2.2/admin/users/<:id>

URL Parameters

Parameter Description
id Unique Id of the user to retrieve

View User by email

package main

import (
    "fmt"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "http://demo.testpress.in//api/v2.2/admin/users/?email=bharathwaaj.s%40gmail.com"

    req, _ := http.NewRequest("GET", url, nil)

    req.Header.Add("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE")
    req.Header.Add("cache-control", "no-cache")
    req.Header.Add("postman-token", "80159c50-160a-991a-f513-a5fafa286a1b")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}

```ruby

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in//api/v2.2/admin/users/?email=bharathwaaj.s%40gmail.com")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE'
request["cache-control"] = 'no-cache'
request["postman-token"] = 'b21426e3-c795-8d2f-eb0b-db5d81ac2ec0'

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

url = "http://demo.testpress.in//api/v2.2/admin/users/"

querystring = {"email":"bharathwaaj.s@gmail.com"}

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE",
    'cache-control': "no-cache",
    'postman-token': "d46170d5-b684-79ad-2ce8-b2c5d8cb5988"
    }

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

print(response.text)
curl -X GET -H "Authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE" -H "Cache-Control: no-cache" -H "Postman-Token: c8cbe2a1-76d0-da3a-1bbb-38cd3f61f215" "http://demo.testpress.in//api/v2.2/admin/users/?email=bharathwaaj.s@gmail.com"
<?php

$request = new HttpRequest();
$request->setUrl('http://demo.testpress.in//api/v2.2/admin/users/');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
  'email' => 'bharathwaaj.s@gmail.com'
));

$request->setHeaders(array(
  'postman-token' => 'f09b000b-ac7c-da00-2532-85010b519a60',
  'cache-control' => 'no-cache',
  'authorization' => 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
var client = new RestClient("http://demo.testpress.in//api/v2.2/admin/users/?email=bharathwaaj.s%40gmail.com");
var request = new RestRequest(Method.GET);
request.AddHeader("postman-token", "30c7ab26-66ed-0558-dd6f-8cc4b66d5644");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE");
IRestResponse response = client.Execute(request);
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://demo.testpress.in//api/v2.2/admin/users/?email=bharathwaaj.s%40gmail.com")
  .get()
  .addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE")
  .addHeader("cache-control", "no-cache")
  .addHeader("postman-token", "05ef17ed-3a9c-3745-ee1b-10ae5963bbcc")
  .build();

Response response = client.newCall(request).execute();

The above command returns JSON structured like this:

{
  "count": 1,
  "next": null,
  "previous": null,
  "per_page": 20,
  "results": [
    {
      "id": 36,
      "url": "http://demo.testpress.in/api/v2.2/admin/users/36/",
      "username": "bharath",
      "first_name": "Bharath Kumar",
      "last_name": "S",
      "display_name": "Bharath Kumar S",
      "email": "bharathwaaj.s@gmail.com",
      "photo": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/cb88287098924bd6ae615ca4aa71eab5.png",
      "large_image": "",
      "medium_image": "",
      "small_image": "",
      "x_small_image": "",
      "mini_image": "",
      "birth_date": "17/08/1987",
      "gender_code": "male",
      "gender": "Male",
      "address1": "257 A Timber Mill Road",
      "address2": "4th Cross, New Thippasandra",
      "city": "Bangalore",
      "zip": "560075",
      "state": "",
      "state_code": "",
      "phone": "9787231006",
      "batches": [
        {
          "id": 26,
          "name": "UPSC Evening Batch",
          "url": "http://demo.testpress.in/api/v2.2/admin/batches/26/"
        },
        {
          "id": 25,
          "name": "IBPS Online Batch",
          "url": "http://demo.testpress.in/api/v2.2/admin/batches/25/"
        },
        {
          "id": 24,
          "name": "NEET Morning Batch",
          "url": "http://demo.testpress.in/api/v2.2/admin/batches/24/"
        },
        {
          "id": 23,
          "name": "UPSC Morning Batch",
          "url": "http://demo.testpress.in/api/v2.2/admin/batches/23/"
        },
        {
          "id": 22,
          "name": "IBPS Morning Batch",
          "url": "http://demo.testpress.in/api/v2.2/admin/batches/22/"
        },
        {
          "id": 21,
          "name": "st std A",
          "url": "http://demo.testpress.in/api/v2.2/admin/batches/21/"
        },
        {
          "id": 20,
          "name": "OHC 2013",
          "url": "http://demo.testpress.in/api/v2.2/admin/batches/20/"
        },
        {
          "id": 19,
          "name": "POZITIVE ONLINE TEST SERIES",
          "url": "http://demo.testpress.in/api/v2.2/admin/batches/19/"
        },
        {
          "id": 18,
          "name": "Unique UPSC Batch",
          "url": "http://demo.testpress.in/api/v2.2/admin/batches/18/"
        }
      ],
      "batches_url": "http://demo.testpress.in/api/v2.2/admin/users/36/batches/"
    }
  ]
}

This endpoint allows you to view details of a particular user by email address

HTTP Request

GET /api/v2.2/admin/users/?email=<:email_id>

URL Parameters

Parameter Description
email Email Address of the user

Fields

Name Type Description
username string Username of the user
first_name string First name of the user
last_name string Last name of the user
display_name string Name of the user to be displayed
email string Email of the user
photo string Original image of the user as uploaded
large_image string Profile image with size 256x256
medium_image string Profile image with size 128x128
small_image string Profile image with size 48x48
xsmall_image string Profile image with size 32x32
mini_image string Profile image with size 24x24
birth_date datestring Birth date of user. Should be in DD/MM/YYYY format
gender_code string Gender of user. Can be “male”, “female” or “trans”
gender string (Read only) Human readable gender of user. Can be “Male”, “Female” or “Transgender”
address1 string Address of user
address2 string Address of user
city string City of user
zip string Pincode of user
state_code string State of user in ISO 3166-2:IN format (https://en.wikipedia.org/wiki/ISO_3166-2:IN)
phone string Phone of user
batches array Batches to which user has access

View batches

curl --request GET \
  --url http://demo.testpress.in/api/v2.2/admin/users/1892/batches/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json'
require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/admin/users/1892/batches/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/admin/users/1892/batches/"

payload = ""
headers = {
    'content-type': "application/json",
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84",
    'cache-control': "no-cache"
    }

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

print(response.text)
var client = new RestClient("http://demo.testpress.in/api/v2.2/admin/users/1892/batches/");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84");
request.AddHeader("content-type", "application/json");
IRestResponse response = client.Execute(request);
<?php

$request = new HttpRequest();
$request->setUrl('http://demo.testpress.in/api/v2.2/admin/users/1892/batches/');
$request->setMethod(HTTP_METH_GET);

$request->setHeaders(array(
  'cache-control' => 'no-cache',
  'authorization' => 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84',
  'content-type' => 'application/json'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://demo.testpress.in/api/v2.2/admin/users/1892/batches/")
  .get()
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();
var http = require("http");

var options = {
  "method": "GET",
  "hostname": "demo.testpress.in",
  "port": null,
  "path": "/api/v2.2/admin/users/1892/batches/",
  "headers": {
    "content-type": "application/json",
    "authorization": "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84",
    "cache-control": "no-cache"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
package main

import (
    "fmt"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "http://demo.testpress.in/api/v2.2/admin/users/1892/batches/"

    req, _ := http.NewRequest("GET", url, nil)

    req.Header.Add("content-type", "application/json")
    req.Header.Add("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84")
    req.Header.Add("cache-control", "no-cache")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}

The above command returns JSON structured like this:

{
  "count": 2,
  "next": null,
  "previous": null,
  "per_page": 20,
  "results": [
    {
      "id": 29,
      "name": "Test Batch",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/29/"
    },
    {
      "id": 23,
      "name": "UPSC Morning Batch",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/23/"
    }
  ]
}

This endpoint allows you to view batches of a particular user.

HTTP Request

GET /api/v2.2/admin/users/<id>/batches/

URL Parameters

Parameter Description
id Unique Id of the user to retrieve

Response Fields

Name Type Description
id string Id of the batch
url string Unique endpoint of that batch
name string Name of the batch

Add batches

curl --request POST \
  --url http://demo.testpress.in/api/v2.2/admin/users/1892/batches/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
  --data '{"batches": ["NEET Morning Batch", "IBPS Morning Batch"]}'
require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/admin/users/1892/batches/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84'
request["cache-control"] = 'no-cache'
request.body = "{\n    \"batches\": [\"NEET Morning Batch\", \"IBPS Morning Batch\"]\n}"

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

url = "http://demo.testpress.in/api/v2.2/admin/users/1892/batches/"

payload = "{\n    \"batches\": [\"NEET Morning Batch\", \"IBPS Morning Batch\"]\n}"
headers = {
    'content-type': "application/json",
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84",
    'cache-control': "no-cache"
    }

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

print(response.text)
var client = new RestClient("http://demo.testpress.in/api/v2.2/admin/users/1892/batches/");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n    \"batches\": [\"NEET Morning Batch\", \"IBPS Morning Batch\"]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
<?php

$request = new HttpRequest();
$request->setUrl('http://demo.testpress.in/api/v2.2/admin/users/1892/batches/');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'cache-control' => 'no-cache',
  'authorization' => 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84',
  'content-type' => 'application/json'
));

$request->setBody('{
    "batches": ["NEET Morning Batch", "IBPS Morning Batch"]
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"batches\": [\"NEET Morning Batch\", \"IBPS Morning Batch\"]\n}");
Request request = new Request.Builder()
  .url("http://demo.testpress.in/api/v2.2/admin/users/1892/batches/")
  .post(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();
var http = require("http");

var options = {
  "method": "POST",
  "hostname": "demo.testpress.in",
  "port": null,
  "path": "/api/v2.2/admin/users/1892/batches/",
  "headers": {
    "content-type": "application/json",
    "authorization": "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84",
    "cache-control": "no-cache"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ batches: [ 'NEET Morning Batch', 'IBPS Morning Batch' ] }));
req.end();
package main

import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "http://demo.testpress.in/api/v2.2/admin/users/1892/batches/"

    payload := strings.NewReader("{\n    \"batches\": [\"NEET Morning Batch\", \"IBPS Morning Batch\"]\n}")

    req, _ := http.NewRequest("POST", url, payload)

    req.Header.Add("content-type", "application/json")
    req.Header.Add("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84")
    req.Header.Add("cache-control", "no-cache")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}

The above command returns JSON structured like this:

[
  {
    "id": 29,
    "name": "Test Batch",
    "url": "http://demo.testpress.in/api/v2.2/admin/batches/29/"
  },
  {
    "id": 24,
    "name": "NEET Morning Batch",
    "url": "http://demo.testpress.in/api/v2.2/admin/batches/24/"
  },
  {
    "id": 23,
    "name": "UPSC Morning Batch",
    "url": "http://demo.testpress.in/api/v2.2/admin/batches/23/"
  },
  {
    "id": 22,
    "name": "IBPS Morning Batch",
    "url": "http://demo.testpress.in/api/v2.2/admin/batches/22/"
  }
]

This endpoint allows you to add users to batches

HTTP Request

POST /api/v2.2/admin/users/<id>/batches/

URL Parameters

Parameter Description
id Unique Id of the user to retrieve

POST data

Parameter Description
batches Array of string of batches names to add the user to

Response Fields

Name Type Description
id string Id of the batch
url string Unique endpoint of that batch
name string Name of the batch

Remove batches

curl --request DELETE \
  --url http://demo.testpress.in/api/v2.2/admin/users/1892/batches/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
  --data '{"batches": ["NEET Morning Batch", "IBPS Morning Batch"]}'
require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/admin/users/1892/batches/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Delete.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84'
request["cache-control"] = 'no-cache'
request.body = "{\n    \"batches\": [\"NEET Morning Batch\", \"IBPS Morning Batch\"]\n}"

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

url = "http://demo.testpress.in/api/v2.2/admin/users/1892/batches/"

payload = "{\n    \"batches\": [\"NEET Morning Batch\", \"IBPS Morning Batch\"]\n}"
headers = {
    'content-type': "application/json",
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84",
    'cache-control': "no-cache"
    }

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

print(response.text)
var client = new RestClient("http://demo.testpress.in/api/v2.2/admin/users/1892/batches/");
var request = new RestRequest(Method.DELETE);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n    \"batches\": [\"NEET Morning Batch\", \"IBPS Morning Batch\"]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
<?php

$request = new HttpRequest();
$request->setUrl('http://demo.testpress.in/api/v2.2/admin/users/1892/batches/');
$request->setMethod(HTTP_METH_DELETE);

$request->setHeaders(array(
  'cache-control' => 'no-cache',
  'authorization' => 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84',
  'content-type' => 'application/json'
));

$request->setBody('{
    "batches": ["NEET Morning Batch", "IBPS Morning Batch"]
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"batches\": [\"NEET Morning Batch\", \"IBPS Morning Batch\"]\n}");
Request request = new Request.Builder()
  .url("http://demo.testpress.in/api/v2.2/admin/users/1892/batches/")
  .delete(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();
var http = require("http");

var options = {
  "method": "DELETE",
  "hostname": "demo.testpress.in",
  "port": null,
  "path": "/api/v2.2/admin/users/1892/batches/",
  "headers": {
    "content-type": "application/json",
    "authorization": "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84",
    "cache-control": "no-cache"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ batches: [ 'NEET Morning Batch', 'IBPS Morning Batch' ] }));
req.end();
package main

import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "http://demo.testpress.in/api/v2.2/admin/users/1892/batches/"

    payload := strings.NewReader("{\n    \"batches\": [\"NEET Morning Batch\", \"IBPS Morning Batch\"]\n}")

    req, _ := http.NewRequest("DELETE", url, payload)

    req.Header.Add("content-type", "application/json")
    req.Header.Add("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84")
    req.Header.Add("cache-control", "no-cache")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}

The above command on success will return 204 NO CONTENT

This endpoint allows you to remove users from batches

HTTP Request

DELETE /api/v2.2/admin/users/<id>/batches/

URL Parameters

Parameter Description
id Unique Id of the user to retrieve

POST data

Parameter Description
batches Array of string of batches names to add the user to

Mentors

Admin Mentors API gives you access to create/view mentors and add/remove students to mentors.

Create mentor

curl --request POST \
  --url http://demo.testpress.in/api/v2.2/admin/mentors/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
  --header 'postman-token: 9624f4b4-d495-aaaa-df27-b99f0cef13b4' \
  --data '{\n    "username": "Georgebobby", \n    "password":"password",\n    "first_name": "George", \n    "last_name": "Bobby", \n    "email": "george@hotmail.com", \n    "birth_date": "03/07/1990", \n    "gender_code": "1", \n    "address1": "21 New Street", \n    "address2": "Chrompet", \n    "city": "Chennai", \n    "zip": "641003", \n    "state_code": "IN-TN", \n    "phone": "9876543210"\n}'
require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/admin/mentors/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k'
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request["postman-token"] = '02729f65-07a8-b865-41cd-09fd9281a489'
request.body = "{\n    \"username\": \"Georgebobby\", \n    \"password\":\"password\",\n    \"first_name\": \"George\", \n    \"last_name\": \"Bobby\", \n    \"email\": \"george@hotmail.com\", \n    \"birth_date\": \"03/07/1990\", \n    \"gender_code\": \"1\", \n    \"address1\": \"21 New Street\", \n    \"address2\": \"Chrompet\", \n    \"city\": \"Chennai\", \n    \"zip\": \"641003\", \n    \"state_code\": \"IN-TN\", \n    \"phone\": \"9876543210\"\n}"

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

url = "http://demo.testpress.in/api/v2.2/admin/mentors/"

payload = "{\n    \"username\": \"Georgebobby\", \n    \"password\":\"password\",\n    \"first_name\": \"George\", \n    \"last_name\": \"Bobby\", \n    \"email\": \"george@hotmail.com\", \n    \"birth_date\": \"03/07/1990\", \n    \"gender_code\": \"1\", \n    \"address1\": \"21 New Street\", \n    \"address2\": \"Chrompet\", \n    \"city\": \"Chennai\", \n    \"zip\": \"641003\", \n    \"state_code\": \"IN-TN\", \n    \"phone\": \"9876543210\"\n}"
headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k",
    'content-type': "application/json",
    'cache-control': "no-cache",
    'postman-token': "59e716f0-4dd8-c677-fbfe-89e8672a1b27"
    }

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

print(response.text)
var client = new RestClient("http://demo.testpress.in/api/v2.2/admin/mentors/");
var request = new RestRequest(Method.POST);
request.AddHeader("postman-token", "60b37cc0-352b-c122-a41f-31a27db2f08d");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k");
request.AddParameter("application/json", "{\n    \"username\": \"Georgebobby\", \n    \"password\":\"password\",\n    \"first_name\": \"George\", \n    \"last_name\": \"Bobby\", \n    \"email\": \"george@hotmail.com\", \n    \"birth_date\": \"03/07/1990\", \n    \"gender_code\": \"1\", \n    \"address1\": \"21 New Street\", \n    \"address2\": \"Chrompet\", \n    \"city\": \"Chennai\", \n    \"zip\": \"641003\", \n    \"state_code\": \"IN-TN\", \n    \"phone\": \"9876543210\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
<?php

$request = new HttpRequest();
$request->setUrl('http://demo.testpress.in/api/v2.2/admin/mentors/');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'postman-token' => '0e6a81e9-0291-ad9a-5e25-a7ab77e950e4',
  'cache-control' => 'no-cache',
  'content-type' => 'application/json',
  'authorization' => 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k'
));

$request->setBody('{
    "username": "Georgebobby", 
    "password":"password",
    "first_name": "George", 
    "last_name": "Bobby", 
    "email": "george@hotmail.com", 
    "birth_date": "03/07/1990", 
    "gender_code": "1", 
    "address1": "21 New Street", 
    "address2": "Chrompet", 
    "city": "Chennai", 
    "zip": "641003", 
    "state_code": "IN-TN", 
    "phone": "9876543210"
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"username\": \"Georgebobby\", \n    \"password\":\"password\",\n    \"first_name\": \"George\", \n    \"last_name\": \"Bobby\", \n    \"email\": \"george@hotmail.com\", \n    \"birth_date\": \"03/07/1990\", \n    \"gender_code\": \"1\", \n    \"address1\": \"21 New Street\", \n    \"address2\": \"Chrompet\", \n    \"city\": \"Chennai\", \n    \"zip\": \"641003\", \n    \"state_code\": \"IN-TN\", \n    \"phone\": \"9876543210\"\n}");
Request request = new Request.Builder()
  .url("http://demo.testpress.in/api/v2.2/admin/mentors/")
  .post(body)
  .addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k")
  .addHeader("content-type", "application/json")
  .addHeader("cache-control", "no-cache")
  .addHeader("postman-token", "cf247a42-9440-685e-dbd6-7ddbf2abc1ea")
  .build();

Response response = client.newCall(request).execute();
var request = require("request");

var options = { method: 'POST',
  url: 'http://demo.testpress.in/api/v2.2/admin/mentors/',
  headers: 
   { 'postman-token': '0c99111c-c13f-eddf-a0bb-0e2eef469765',
     'cache-control': 'no-cache',
     'content-type': 'application/json',
     authorization: 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k' },
  body: 
   { username: 'Georgebobby',
     password: 'password',
     first_name: 'George',
     last_name: 'Bobby',
     email: 'george@hotmail.com',
     birth_date: '03/07/1990',
     gender_code: '1',
     address1: '21 New Street',
     address2: 'Chrompet',
     city: 'Chennai',
     zip: '641003',
     state_code: 'IN-TN',
     phone: '9876543210' },
  json: true };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

package main

import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "http://demo.testpress.in/api/v2.2/admin/mentors/"

    payload := strings.NewReader("{\n    \"username\": \"Georgebobby\", \n    \"password\":\"password\",\n    \"first_name\": \"George\", \n    \"last_name\": \"Bobby\", \n    \"email\": \"george@hotmail.com\", \n    \"birth_date\": \"03/07/1990\", \n    \"gender_code\": \"1\", \n    \"address1\": \"21 New Street\", \n    \"address2\": \"Chrompet\", \n    \"city\": \"Chennai\", \n    \"zip\": \"641003\", \n    \"state_code\": \"IN-TN\", \n    \"phone\": \"9876543210\"\n}")

    req, _ := http.NewRequest("POST", url, payload)

    req.Header.Add("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k")
    req.Header.Add("content-type", "application/json")
    req.Header.Add("cache-control", "no-cache")
    req.Header.Add("postman-token", "bc7f391f-c86e-08ed-49f0-0f6dcf281628")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}

The above command returns JSON structured like this:

{
  "id": 45,
  "username": "Georgebobby",
  "email": "george@hotmail.com",
  "first_name": "George",
  "last_name": "Bobby",
  "display_name": "George Bobby",
  "gender": "Male",
  "state": "Tamil Nadu",
  "created": "2016-09-28T19:06:18.177Z",
  "students": {
    "url": "http://demo.testpress.in/api/v2.2/admin/mentors/45/students/",
    "students_count": 0
  }
}

This endpoint creates a mentor.

HTTP Request

POST /api/v2.2/admin/mentors/

Fields

Name Type Description
username string Username of the mentor
password string password of the mentor
first_name string First name of the mentor
last_name string Last name of the mentor
email string Email of the mentor
birth_date datestring Birth date of mentor. Should be in DD/MM/YYYY format
gender_code string Gender of mentor. Can be “male”, “female” or “trans”
address1 string Address of mentor
address2 string Address of mentor
city string City of mentor
zip string Pincode of mentor
state_code string State of mentor in ISO 3166-2:IN format (https://en.wikipedia.org/wiki/ISO_3166-2:IN)
phone string Phone of mentor

View mentors

curl --request GET \
  --url http://demo.testpress.in/api/v2.2/admin/mentors/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
  --header 'postman-token: 7b270310-b1fe-2434-5f1d-d6a5d4c5db73'
require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/admin/mentors/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k'
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request["postman-token"] = '67539d2b-a84b-0fc5-93b0-edd440c52eac'

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

url = "http://demo.testpress.in/api/v2.2/admin/mentors/"

payload = ""
headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k",
    'content-type': "application/json",
    'cache-control': "no-cache",
    'postman-token': "8c7a6a33-7a97-bc62-e0bf-bc20d70d5ca1"
    }

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

print(response.text)
var client = new RestClient("http://demo.testpress.in/api/v2.2/admin/mentors/");
var request = new RestRequest(Method.GET);
request.AddHeader("postman-token", "b47a7b07-ea80-4e8d-103c-144d2dcf8224");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k");
IRestResponse response = client.Execute(request);
<?php

$request = new HttpRequest();
$request->setUrl('http://demo.testpress.in/api/v2.2/admin/mentors/');
$request->setMethod(HTTP_METH_GET);

$request->setHeaders(array(
  'postman-token' => '4158e1f7-9216-65d7-618f-8c1e1becd02e',
  'cache-control' => 'no-cache',
  'content-type' => 'application/json',
  'authorization' => 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://demo.testpress.in/api/v2.2/admin/mentors/")
  .get()
  .addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k")
  .addHeader("content-type", "application/json")
  .addHeader("cache-control", "no-cache")
  .addHeader("postman-token", "c28bed97-ec00-8378-ce56-8534eba3daa7")
  .build();

Response response = client.newCall(request).execute();
var request = require("request");

var options = { method: 'GET',
  url: 'http://demo.testpress.in/api/v2.2/admin/mentors/',
  headers: 
   { 'postman-token': 'b236d859-b023-f064-0207-491f9ec1be11',
     'cache-control': 'no-cache',
     'content-type': 'application/json',
     authorization: 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

package main

import (
    "fmt"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "http://demo.testpress.in/api/v2.2/admin/mentors/"

    req, _ := http.NewRequest("GET", url, nil)

    req.Header.Add("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k")
    req.Header.Add("content-type", "application/json")
    req.Header.Add("cache-control", "no-cache")
    req.Header.Add("postman-token", "1b0c4aeb-92af-f89a-a3d3-21dcedc3d55b")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}

The above command returns JSON structured like this:

 [
    {
      "id": 44,
      "username": "Steevwilliam",
      "email": "steev@yahoomail.com",
      "first_name": "Steev",
      "last_name": "William",
      "display_name": "Steev William",
      "gender": "Male",
      "state": "Tamil Nadu",
      "created": "2016-09-28T18:44:54.081Z",
      "students": {
        "url": "http://demo.testpress.in/api/v2.2/admin/mentors/44/students/",
        "students_count": 150
      }
    },
    {
      "id": 45,
      "username": "Georgebobby",
      "email": "george@hotmail.com",
      "first_name": "George",
      "last_name": "Bobby",
      "display_name": "George Bobby",
      "gender": "Male",
      "state": "Tamil Nadu",
      "created": "2016-09-28T19:06:18.177Z",
      "students": {
        "url": "http://demo.testpress.in/api/v2.2/admin/mentors/45/students/",
        "students_count": 100
      }
    }
  ]

This endpoint allows you to view all the mentors.

HTTP Request

GET /api/v2.2/admin/mentors/

Response Fields

Name Type Description
id int The mentor unique ID
username string Username of the mentor
first_name string First name of the mentor
last_name string Last name of the mentor
display_name string Display name of the mentor
gender string Gender of the mentor
state string State of the mentor
created datetimefield Date and time when mentor created
students array Student details.

View students

curl --request GET \
  --url http://demo.testpress.in/api/v2.2/admin/mentors/1/students \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
  --header 'postman-token: 14b92c4f-a0ad-fafb-67f4-5dc5d47ae832'
require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/admin/mentors/1/students")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k'
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request["postman-token"] = 'c7e923f3-3290-928a-29d3-d9f4ae589475'

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

url = "http://demo.testpress.in/api/v2.2/admin/mentors/1/students"

payload = ""
headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k",
    'content-type': "application/json",
    'cache-control': "no-cache",
    'postman-token': "21520f53-8880-2ab4-90b9-c4534e11be8e"
    }

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

print(response.text)
var client = new RestClient("http://demo.testpress.in/api/v2.2/admin/mentors/1/students");
var request = new RestRequest(Method.GET);
request.AddHeader("postman-token", "578c57d3-b414-1c0c-5ecc-27ec3809871c");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k");
IRestResponse response = client.Execute(request);
<?php

$request = new HttpRequest();
$request->setUrl('http://demo.testpress.in/api/v2.2/admin/mentors/1/students');
$request->setMethod(HTTP_METH_GET);

$request->setHeaders(array(
  'postman-token' => '4ddf538f-c113-cf40-348e-ae627abc6137',
  'cache-control' => 'no-cache',
  'content-type' => 'application/json',
  'authorization' => 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("http://demo.testpress.in/api/v2.2/admin/mentors/1/students")
  .get()
  .addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k")
  .addHeader("content-type", "application/json")
  .addHeader("cache-control", "no-cache")
  .addHeader("postman-token", "62de973a-a5ce-8753-ac75-274ac3e3976c")
  .build();

Response response = client.newCall(request).execute();
var http = require("http");

var options = {
  "method": "GET",
  "hostname": "demo.testpress.in",
  "port": null,
  "path": "/api/v2.2/admin/mentors/1/students",
  "headers": {
    "authorization": "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k",
    "content-type": "application/json",
    "cache-control": "no-cache",
    "postman-token": "d6e1e7fc-e06a-e141-5cc2-918fe49c6a71"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
package main

import (
    "fmt"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "http://demo.testpress.in/api/v2.2/admin/mentors/1/students"

    req, _ := http.NewRequest("GET", url, nil)

    req.Header.Add("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k")
    req.Header.Add("content-type", "application/json")
    req.Header.Add("cache-control", "no-cache")
    req.Header.Add("postman-token", "baabfe98-3c44-47df-4675-89b353f3b3e4")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}

The above command returns JSON structured like this:

[
    {
      "id": 2,
      "url": "http://demo.testpress.in/api/v2.2/admin/users/2/",
      "username": "testpress",
      "first_name": "John",
      "last_name": "Appleseed",
      "display_name": "John Appleseed",
      "email": "selvasteephandfasdfasdf@gmail.com",
      "photo": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/d1b9192ef434443a963eced9b8747862.jpeg",
      "large_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/2e6f0eb3bc9d467ab4254c094b47611e.jpeg",
      "medium_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/7552ce50dff6479ba172f1102c56e72d.jpeg",
      "small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/05764a619f09474d93caf0d49a43a4c0.jpeg",
      "x_small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/5ae9976cc2224e08ab81510404dd8c93.jpeg",
      "mini_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/34d189e496f140b3aa772ee19df46e1b.jpeg",
      "birth_date": "27/08/1994",
      "gender_code": "male",
      "gender": "Male",
      "address1": "Chennai",
      "address2": "Chennai",
      "city": "Chennai",
      "zip": "600069",
      "state": "",
      "state_code": "",
      "phone": "9043570576",
      "batches": [
        {
          "id": 30,
          "name": "Testing Batch 1",
          "url": "http://demo.testpress.in/api/v2.2/admin/batches/30/"
        },
        {
          "id": 29,
          "name": "new sample batch",
          "url": "http://demo.testpress.in/api/v2.2/admin/batches/29/"
        }
      ],
      "batches_url": "http://demo.testpress.in/api/v2.2/admin/users/2/batches/"
    },
    {
      "id": 345,
      "url": "http://demo.testpress.in/api/v2.2/admin/users/345/",
      "username": "hellouser",
      "first_name": "hellouser",
      "last_name": "",
      "display_name": "hellouser",
      "email": "testingsocialauth@gmail.com",
      "photo": null,
      "large_image": "",
      "medium_image": "",
      "small_image": "",
      "x_small_image": "",
      "mini_image": "",
      "birth_date": null,
      "gender_code": null,
      "gender": null,
      "address1": "",
      "address2": "",
      "city": "",
      "zip": "",
      "state": "",
      "state_code": "",
      "phone": "9898989898",
      "batches": [
        {
          "id": 40,
          "name": "Payubatch",
          "url": "http://demo.testpress.in/api/v2.2/admin/batches/40/"
        },
        {
          "id": 29,
          "name": "new sample batch",
          "url": "http://demo.testpress.in/api/v2.2/admin/batches/29/"
        },
        {
          "id": 16,
          "name": "EEE",
          "url": "http://demo.testpress.in/api/v2.2/admin/batches/16/"
        }
      ],
      "batches_url": "http://demo.testpress.in/api/v2.2/admin/users/345/batches/"
    }
]

This endpoint allows you to view students of a particular mentor.

HTTP Request

GET /api/v2.2/admin/mentors/<:id>/students/

URL Parameters

Parameter Description
id Unique Id of the mentor to retrieve

Response Fields

Name Type Description
id int Unique Id of the student
username string Username of the student
first_name string First name of the student
last_name string Last name of the student
display_name string Name of the student to be displayed
email string Email of the student
photo string Original image of the student as uploaded
large_image string Profile image with size 256x256
medium_image string Profile image with size 128x128
small_image string Profile image with size 48x48
xsmall_image string Profile image with size 32x32
mini_image string Profile image with size 24x24
birth_date datestring Birth date of student. Should be in DD/MM/YYYY format
gender_code string Gender of student. Can be “male”, “female” or “trans”
gender string (Read only) Human readable gender of student. Can be “Male”, “Female” or “Transgender”
address1 string Address of student
address2 string Address of student
city string City of student
zip string Pincode of student
state_code string State of student in ISO 3166-2:IN format (https://en.wikipedia.org/wiki/ISO_3166-2:IN)
phone string Phone of student
batches array Batches to which student has access

Add students

curl --request POST \
  --url http://demo.testpress.in/api/v2.2/admin/mentors/1/students/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
  --header 'postman-token: 30305f4a-5150-4ff7-5781-30f4ab972452' \
  --data '{ \n    "students_username": [ "john", "ragav"]\n}'
require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/admin/mentors/1/students/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k'
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request["postman-token"] = '1cca976b-d71f-613b-42f1-d7bf703edb35'
request.body = "{ \n    \"students_username\": [ \"john\", \"ragav\"]\n}"

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

url = "http://demo.testpress.in/api/v2.2/admin/mentors/1/students/"

payload = "{ \n    \"students_username\": [ \"john\", \"ragav\"]\n}"
headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k",
    'content-type': "application/json",
    'cache-control': "no-cache",
    'postman-token': "9c4eee2e-3472-3a2e-adc7-70bc448f4c04"
    }

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

print(response.text)
var client = new RestClient("http://demo.testpress.in/api/v2.2/admin/mentors/1/students/");
var request = new RestRequest(Method.POST);
request.AddHeader("postman-token", "6c43c51e-a280-50cd-78ba-5685f9db8730");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k");
request.AddParameter("application/json", "{ \n    \"students_username\": [ \"john\", \"ragav\"]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
<?php

$request = new HttpRequest();
$request->setUrl('http://demo.testpress.in/api/v2.2/admin/mentors/1/students/');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'postman-token' => '0ff6afca-b158-a349-172b-f9b4c3f02cec',
  'cache-control' => 'no-cache',
  'content-type' => 'application/json',
  'authorization' => 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k'
));

$request->setBody('{ 
    "students_username": [ "john", "ragav"]
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \n    \"students_username\": [ \"john\", \"ragav\"]\n}");
Request request = new Request.Builder()
  .url("http://demo.testpress.in/api/v2.2/admin/mentors/1/students/")
  .post(body)
  .addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k")
  .addHeader("content-type", "application/json")
  .addHeader("cache-control", "no-cache")
  .addHeader("postman-token", "38897bdf-4b68-bd5c-47a0-688b558d3012")
  .build();

Response response = client.newCall(request).execute();
var http = require("http");

var options = {
  "method": "POST",
  "hostname": "demo.testpress.in",
  "port": null,
  "path": "/api/v2.2/admin/mentors/1/students/",
  "headers": {
    "authorization": "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k",
    "content-type": "application/json",
    "cache-control": "no-cache",
    "postman-token": "d8350bb5-db23-fbe7-bd3a-6e5daa8d9ed6"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ students_username: [ 'john', 'ragav' ] }));
req.end();
package main

import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "http://demo.testpress.in/api/v2.2/admin/mentors/1/students/"

    payload := strings.NewReader("{ \n    \"students_username\": [ \"john\", \"ragav\"]\n}")

    req, _ := http.NewRequest("POST", url, payload)

    req.Header.Add("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k")
    req.Header.Add("content-type", "application/json")
    req.Header.Add("cache-control", "no-cache")
    req.Header.Add("postman-token", "39860c6a-72fc-ce61-ab91-aa7746a041ff")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}

The above command returns JSON structured like this:

[
  {
    "id": 2,
    "url": "http://demo.testpress.in/api/v2.2/admin/users/2/",
    "username": "john",
    "first_name": "John",
    "last_name": "Appleseed",
    "display_name": "John Appleseed",
    "email": "selvasteephandfasdfasdf@gmail.com",
    "photo": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/d1b9192ef434443a963eced9b8747862.jpeg",
    "large_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/2e6f0eb3bc9d467ab4254c094b47611e.jpeg",
    "medium_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/7552ce50dff6479ba172f1102c56e72d.jpeg",
    "small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/05764a619f09474d93caf0d49a43a4c0.jpeg",
    "x_small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/5ae9976cc2224e08ab81510404dd8c93.jpeg",
    "mini_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/34d189e496f140b3aa772ee19df46e1b.jpeg",
    "birth_date": "27/08/1994",
    "gender_code": "male",
    "gender": "Male",
    "address1": "Chennai",
    "address2": "Chennai",
    "city": "Chennai",
    "zip": "600069",
    "state": "",
    "state_code": "",
    "phone": "9043570576",
    "batches": [
      {
        "id": 30,
        "name": "Testing Batch 1",
        "url": "http://demo.testpress.in/api/v2.2/admin/batches/30/"
      },
      {
        "id": 29,
        "name": "new sample batch",
        "url": "http://demo.testpress.in/api/v2.2/admin/batches/29/"
      }
    ],
    "batches_url": "http://demo.testpress.in/api/v2.2/admin/users/2/batches/"
  },
  {
    "id": 345,
    "url": "http://demo.testpress.in/api/v2.2/admin/users/345/",
    "username": "ragav",
    "first_name": "ragav",
    "last_name": "",
    "display_name": "ragav",
    "email": "ragav@gmail.com",
    "photo": null,
    "large_image": "",
    "medium_image": "",
    "small_image": "",
    "x_small_image": "",
    "mini_image": "",
    "birth_date": null,
    "gender_code": null,
    "gender": null,
    "address1": "",
    "address2": "",
    "city": "",
    "zip": "",
    "state": "",
    "state_code": "",
    "phone": "9898989898",
    "batches": [
      {
        "id": 40,
        "name": "Payubatch",
        "url": "http://demo.testpress.in/api/v2.2/admin/batches/40/"
      },
      {
        "id": 29,
        "name": "new sample batch",
        "url": "http://demo.testpress.in/api/v2.2/admin/batches/29/"
      },
      {
        "id": 16,
        "name": "EEE",
        "url": "http://demo.testpress.in/api/v2.2/admin/batches/16/"
      }
    ],
    "batches_url": "http://demo.testpress.in/api/v2.2/admin/users/345/batches/"
  }
]

This endpoint allows you to add a students to a mentor.

HTTP Request

POST /api/v2.2/admin/mentors/<:id>/students

URL Parameters

Parameter Description
id Unique Id of the mentor to retrieve

POST data

Parameter Description
students_username Array of students username

Response Fields

Name Type Description
id int Unique Id of the student
username string Username of the student
first_name string First name of the student
last_name string Last name of the student
display_name string Name of the student to be displayed
email string Email of the student
photo string Original image of the student as uploaded
large_image string Profile image with size 256x256
medium_image string Profile image with size 128x128
small_image string Profile image with size 48x48
xsmall_image string Profile image with size 32x32
mini_image string Profile image with size 24x24
birth_date datestring Birth date of student. Should be in DD/MM/YYYY format
gender_code string Gender of student. Can be “male”, “female” or “trans”
gender string (Read only) Human readable gender of student. Can be “Male”, “Female” or “Transgender”
address1 string Address of student
address2 string Address of student
city string City of student
zip string Pincode of student
state_code string State of student in ISO 3166-2:IN format (https://en.wikipedia.org/wiki/ISO_3166-2:IN)
phone string Phone of student
batches array Batches to which student has access

Remove students

curl --request DELETE \
  --url http://demo.testpress.in/api/v2.2/admin/mentors/1/students/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
  --header 'postman-token: 7cd40e60-ac91-ddc3-e493-b103a6b0c2e7' \
  --data '{ \n    "students_username": [ "john", "ragav"]\n}'
require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/admin/mentors/1/students/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Delete.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k'
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request["postman-token"] = '0228eca4-a3af-ed7f-4637-65d4392548c9'
request.body = "{ \n    \"students_username\": [ \"john\", \"ragav\"]\n}"

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

url = "http://demo.testpress.in/api/v2.2/admin/mentors/1/students/"

payload = "{ \n    \"students_username\": [ \"john\", \"ragav\"]\n}"
headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k",
    'content-type': "application/json",
    'cache-control': "no-cache",
    'postman-token': "a6cc65e9-35bd-d2ab-74c7-82a83bbc50e0"
    }

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

print(response.text)
var client = new RestClient("http://demo.testpress.in/api/v2.2/admin/mentors/1/students/");
var request = new RestRequest(Method.DELETE);
request.AddHeader("postman-token", "ceeb1432-1778-4e7c-92f2-7ca1dde9b6a2");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k");
request.AddParameter("application/json", "{ \n    \"students_username\": [ \"john\", \"ragav\"]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
<?php

$request = new HttpRequest();
$request->setUrl('http://demo.testpress.in/api/v2.2/admin/mentors/1/students/');
$request->setMethod(HTTP_METH_DELETE);

$request->setHeaders(array(
  'postman-token' => 'fcd88f65-8d4a-5a0b-20ee-36ffa49a753f',
  'cache-control' => 'no-cache',
  'content-type' => 'application/json',
  'authorization' => 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k'
));

$request->setBody('{ 
    "students_username": [ "john", "ragav"]
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \n    \"students_username\": [ \"john\", \"ragav\"]\n}");
Request request = new Request.Builder()
  .url("http://demo.testpress.in/api/v2.2/admin/mentors/1/students/")
  .delete(body)
  .addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k")
  .addHeader("content-type", "application/json")
  .addHeader("cache-control", "no-cache")
  .addHeader("postman-token", "5c4514c1-b20f-867d-4daa-bf10708dc01e")
  .build();

Response response = client.newCall(request).execute();
var http = require("http");

var options = {
  "method": "DELETE",
  "hostname": "demo.testpress.in",
  "port": null,
  "path": "/api/v2.2/admin/mentors/1/students/",
  "headers": {
    "authorization": "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k",
    "content-type": "application/json",
    "cache-control": "no-cache",
    "postman-token": "55152e63-d460-2456-ed63-bf5c716365a8"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ students_username: [ 'john', 'ragav' ] }));
req.end();
package main

import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "http://demo.testpress.in/api/v2.2/admin/mentors/1/students/"

    payload := strings.NewReader("{ \n    \"students_username\": [ \"john\", \"ragav\"]\n}")

    req, _ := http.NewRequest("DELETE", url, payload)

    req.Header.Add("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6InN0ZWVwaGFuc2VsdmFyYWpAdGVzdHByZXNzLmluIiwiZXhwIjoxNDc1MDYyMTkwfQ.iwVg_UM4HBB6qs21fe2b6FlNz_JjRfqcs2VTML4Te3k")
    req.Header.Add("content-type", "application/json")
    req.Header.Add("cache-control", "no-cache")
    req.Header.Add("postman-token", "056ddd52-a1bb-2934-09df-82c5f03a1c96")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}

The above command on success will return 204 NO CONTENT

This endpoint allows you to remove students from mentor.

HTTP Request

DELETE /api/v2.2/admin/mentors/<:id>/students

URL Parameters

Parameter Description
id Unique Id of the mentor to retrieve

POST data

Parameter Description
students_username Array of students username

Attempts

All operations related to user attempt can be done using the following end points.

Create an attempt by HMAC

HTTP Request

POST <exam_url>

exam_url can be taken from Testpress Admin dashboard. Once an exam is created, URL can be copied from Exam’s List Page

Fields

Name Type Description
email string Email Address of the user
first_name string First name of the user
institute_attempt_id string Unique reference string generated at your end (Institute’s end). This can be used to track a particular attempt.
key string Public institute key provided by Testpress to identify the Institute
time string Time since epoch used during the HMAC creation
hmac string HMAC generated using the below algorithm
surl url Percentage encoded URL to be called by Testpress after successful completion of the exam

How to create HMAC

HMAC (Hash-based message authentication code) is used to avoid tampering during the request flow. We use a time based HMAC algorithm to limit the lifetime of the HMAC.

The HMAC is calculated using the following algorithm:

message = email|first_name|institute_attempt_id|key|time hmac.new(secret, message, hashlib.sha256).hexdigest()

import hashlib, hmac, time
epoch_time = int(time.time())
message = '|'.join([email, exam_title, first_name, institute_attempt_id, key, epoch_time ])
return hmac.new(secret, message, hashlib.sha256).hexdigest()

Response Parameters for Attempt Creation

Below are the response parameters posted by Testpress to Institute when an exam is completed / cancelled

Name Type Description
email string Email Address of the user
first_name string First name of the user
attempt_id string Unique Testpress Id for the Attempt. This id will be used to review the attempt
institute_attempt_id string Unique reference string generated and passed during attempt creation
total_count string Total number of questions in the Exam
correct_count string Total number of correct attempts by the user
incorrect_count string Total number of incorrect attempts
unanswered_count string Total number of unattemptted questions
score string Score gained by the student
max_score string Maximum grade for the test
rank string Student’s rank. Rank will be set only if the ranks are enabled for the exam
max_rank string Total number of students attemptted the exam
percentage string Score percentage
status string completed / cancelled / pending
hmac string HMAC generated using above algorithm. Same algorithm as Attempt Creation

Review Exam attempt by HMAC

HTTP Request

How to create HMAC

HMAC (Hash-based message authentication code) is used to avoid tampering during the request flow. We use a time based HMAC algorithm to limit the lifetime of the HMAC.

The HMAC is calculated using the following algorithm:

message = id|institute_attempt_id|key|time hmac.new(secret, message, hashlib.sha256).hexdigest()

GET /exams/attempts/?id=<id>&hmac=<hmac>&time=<time>

Name Type Description
id string Attempt ID provided by testpress
institute_attempt_id string Institute’s attempy Id
key string Public institute key provided by Testpress to identify the Institute
time string Time since epoch used during the HMAC creation
hmac string HMAC generated using the above algorithm

Batches

Batches API lets you create and retrieve batches in your institute.

Get All batches

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/admin/batches/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTgsInVzZXJfaWQiOjE4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzMTEyNzl9.fDF03EIOEoXTyVUA3sN9-biUGhWrzO_NIZo1KYCUkbU'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/admin/batches/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTgsInVzZXJfaWQiOjE4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzMTEyNzl9.fDF03EIOEoXTyVUA3sN9-biUGhWrzO_NIZo1KYCUkbU",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/admin/batches/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTgsInVzZXJfaWQiOjE4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzMTEyNzl9.fDF03EIOEoXTyVUA3sN9-biUGhWrzO_NIZo1KYCUkbU' \
  --header 'cache-control: no-cache'
var client = new RestClient("http://demo.testpress.in/api/v2.2/admin/batches/");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTgsInVzZXJfaWQiOjE4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzMTEyNzl9.fDF03EIOEoXTyVUA3sN9-biUGhWrzO_NIZo1KYCUkbU");
IRestResponse response = client.Execute(request);
var http = require("http");

var options = {
  "method": "GET",
  "hostname": "demo.testpress.in",
  "port": null,
  "path": "/api/v2.2/admin/batches/",
  "headers": {
    "content-type": "application/json",
    "authorization": "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc",
    "cache-control": "no-cache",
    "postman-token": "fcdc5d46-d477-3310-5221-d7e228714def"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ username: 'admin15',
  password: 'demouser',
  first_name: 'Cool',
  last_name: 'dude',
  email: 'cool@dude.com',
  birth_date: '03/07/2016',
  gender_code: 'trans',
  state_code: 'IN-TN' }));
req.end();
<?php

$request = new HttpRequest();
$request->setUrl('http://demo.testpress.in/api/v2.2/admin/batches/');
$request->setMethod(HTTP_METH_GET);

$request->setHeaders(array(
  'postman-token' => '4805a06e-813c-0357-dad6-d9c66de97a19',
  'cache-control' => 'no-cache',
  'authorization' => 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc',
  'content-type' => 'application/json'
));

$request->setBody('{
    "username": "admin15",
    "password": "demouser",
    "first_name": "Cool",
    "last_name": "dude",
    "email": "cool@dude.com",
    "birth_date": "03/07/2016",
    "gender_code": "trans",
    "state_code": "IN-TN"
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"username\": \"admin15\",\n    \"password\": \"demouser\",\n    \"first_name\": \"Cool\",\n    \"last_name\": \"dude\",\n    \"email\": \"cool@dude.com\",\n    \"birth_date\": \"03/07/2016\",\n    \"gender_code\": \"trans\",\n    \"state_code\": \"IN-TN\"\n}");
Request request = new Request.Builder()
  .url("http://demo.testpress.in/api/v2.2/admin/batches/")
  .get()
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc")
  .addHeader("cache-control", "no-cache")
  .addHeader("postman-token", "8fd29aa5-9e74-0228-a86e-43c26a6cbb18")
  .build();

Response response = client.newCall(request).execute();
package main

import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "http://demo.testpress.in/api/v2.2/admin/batches/"

    payload := strings.NewReader("{\n    \"username\": \"admin15\",\n    \"password\": \"demouser\",\n    \"first_name\": \"Cool\",\n    \"last_name\": \"dude\",\n    \"email\": \"cool@dude.com\",\n    \"birth_date\": \"03/07/2016\",\n    \"gender_code\": \"trans\",\n    \"state_code\": \"IN-TN\"\n}")

    req, _ := http.NewRequest("GET", url, payload)

    req.Header.Add("content-type", "application/json")
    req.Header.Add("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc")
    req.Header.Add("cache-control", "no-cache")
    req.Header.Add("postman-token", "3155a52d-668f-5e94-6d39-d65d975d939a")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}

The above command returns JSON structured like this:

{
  "count": 21,
  "next": "http://demo.testpress.in/api/v2.2/admin/batches/?page=2",
  "previous": null,
  "per_page": 20,
  "results": [
    {
      "id": 33,
      "name": "TNPSC DEMO EXAM BATCH",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/33/"
    },
    {
      "id": 32,
      "name": "Orient Ias Test Batch",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/32/"
    },
    {
      "id": 31,
      "name": "Super Profs Test batch",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/31/"
    },
    {
      "id": 30,
      "name": "Sample new",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/30/"
    },
    {
      "id": 29,
      "name": "Test Batch",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/29/"
    },
    {
      "id": 28,
      "name": "9th Students Tambaram 2016",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/28/"
    },
    {
      "id": 27,
      "name": "8th Standard Tambaram 2016",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/27/"
    },
    {
      "id": 26,
      "name": "UPSC Evening Batch",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/26/"
    },
    {
      "id": 25,
      "name": "IBPS Online Batch",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/25/"
    },
    {
      "id": 24,
      "name": "NEET Morning Batch",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/24/"
    },
    {
      "id": 23,
      "name": "UPSC Morning  Batch",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/23/"
    },
    {
      "id": 22,
      "name": "IBPS Morning Batch",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/22/"
    },
    {
      "id": 21,
      "name": "st std A",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/21/"
    },
    {
      "id": 20,
      "name": "OHC 2013",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/20/"
    },
    {
      "id": 19,
      "name": "POZITIVE ONLINE TEST SERIES",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/19/"
    },
    {
      "id": 18,
      "name": "Unique UPSC Batch",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/18/"
    },
    {
      "id": 17,
      "name": "ECE",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/17/"
    },
    {
      "id": 16,
      "name": "EEE",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/16/"
    },
    {
      "id": 15,
      "name": "DISHA BATCH 1",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/15/"
    },
    {
      "id": 2,
      "name": "Career Anna Test Batch",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/2/"
    }
  ]
}

This endpoint retreives all the batches available in your institute

HTTP Request

GET /api/v2.2/admin/batches/

Query Parameters

Parameter Type Description
q string Filters by batch name.

Fields

Name Type Description
id int The batch unique ID
name string Batch’s Name
url string URL to get details of the batch

Get a single Batch

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/admin/batches/26/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTgsInVzZXJfaWQiOjE4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzMTEyNzl9.fDF03EIOEoXTyVUA3sN9-biUGhWrzO_NIZo1KYCUkbU'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/admin/batches/26/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTgsInVzZXJfaWQiOjE4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzMTEyNzl9.fDF03EIOEoXTyVUA3sN9-biUGhWrzO_NIZo1KYCUkbU",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/admin/batches/26/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTgsInVzZXJfaWQiOjE4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzMTEyNzl9.fDF03EIOEoXTyVUA3sN9-biUGhWrzO_NIZo1KYCUkbU' \
  --header 'cache-control: no-cache'
var client = new RestClient("http://demo.testpress.in/api/v2.2/admin/batches/26/");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTgsInVzZXJfaWQiOjE4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzMTEyNzl9.fDF03EIOEoXTyVUA3sN9-biUGhWrzO_NIZo1KYCUkbU");
IRestResponse response = client.Execute(request);
<?php

$request = new HttpRequest();
$request->setUrl('http://demo.testpress.in/api/v2.2/admin/batches/26/');
$request->setMethod(HTTP_METH_GET);

$request->setHeaders(array(
  'postman-token' => 'f4169b65-54de-6ae9-cd88-aefbed547762',
  'cache-control' => 'no-cache',
  'authorization' => 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc',
  'content-type' => 'application/json'
));

$request->setBody('{
    "username": "admin15",
    "password": "demouser",
    "first_name": "Cool",
    "last_name": "dude",
    "email": "cool@dude.com",
    "birth_date": "03/07/2016",
    "gender_code": "trans",
    "state_code": "IN-TN"
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
var http = require("http");

var options = {
  "method": "GET",
  "hostname": "demo.testpress.in",
  "port": null,
  "path": "/api/v2.2/admin/batches/26/",
  "headers": {
    "content-type": "application/json",
    "authorization": "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc",
    "cache-control": "no-cache",
    "postman-token": "1864d84e-3ca4-5ea6-e8a4-ae1255d4dfa4"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ username: 'admin15',
  password: 'demouser',
  first_name: 'Cool',
  last_name: 'dude',
  email: 'cool@dude.com',
  birth_date: '03/07/2016',
  gender_code: 'trans',
  state_code: 'IN-TN' }));
req.end();
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"username\": \"admin15\",\n    \"password\": \"demouser\",\n    \"first_name\": \"Cool\",\n    \"last_name\": \"dude\",\n    \"email\": \"cool@dude.com\",\n    \"birth_date\": \"03/07/2016\",\n    \"gender_code\": \"trans\",\n    \"state_code\": \"IN-TN\"\n}");
Request request = new Request.Builder()
  .url("http://demo.testpress.in/api/v2.2/admin/batches/26/")
  .get()
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc")
  .addHeader("cache-control", "no-cache")
  .addHeader("postman-token", "46709ba6-3acc-5146-7ec9-3831296a9706")
  .build();

Response response = client.newCall(request).execute();
package main

import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "http://demo.testpress.in/api/v2.2/admin/batches/26/"

    payload := strings.NewReader("{\n    \"username\": \"admin15\",\n    \"password\": \"demouser\",\n    \"first_name\": \"Cool\",\n    \"last_name\": \"dude\",\n    \"email\": \"cool@dude.com\",\n    \"birth_date\": \"03/07/2016\",\n    \"gender_code\": \"trans\",\n    \"state_code\": \"IN-TN\"\n}")

    req, _ := http.NewRequest("GET", url, payload)

    req.Header.Add("content-type", "application/json")
    req.Header.Add("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc")
    req.Header.Add("cache-control", "no-cache")
    req.Header.Add("postman-token", "fa463bee-bff9-2c2e-3ff0-1828417d1b82")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}

The above command returns JSON structured like this:

{
  "id": 26,
  "name": "UPSC Evening Batch",
  "url": "http://demo.testpress.in/api/v2.2/admin/batches/26/"
} 

This endpoint retreives details of single batch

HTTP Request

GET /api/v2.2/admin/batches/<id>

URL Parameters

Parameter Description
id Unique Id of the batch to retrieve

Create a batch

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/admin/batches/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTgsInVzZXJfaWQiOjE4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzMTEyNzl9.fDF03EIOEoXTyVUA3sN9-biUGhWrzO_NIZo1KYCUkbU'
request["cache-control"] = 'no-cache'
request.body = "{\n    \"name\": \"Online Test Batch\"\n}"

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

url = "http://demo.testpress.in/api/v2.2/admin/batches/"
payload = "{\n    \"name\": \"Online Test Batch\"\n}"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTgsInVzZXJfaWQiOjE4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzMTEyNzl9.fDF03EIOEoXTyVUA3sN9-biUGhWrzO_NIZo1KYCUkbU",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request POST \
  --url http://demo.testpress.in/api/v2.2/admin/batches/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTgsInVzZXJfaWQiOjE4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzMTEyNzl9.fDF03EIOEoXTyVUA3sN9-biUGhWrzO_NIZo1KYCUkbU' \
  --header 'cache-control: no-cache' \
  --data '{\n    "name": "Online Test Batch"\n}'
var client = new RestClient("http://demo.testpress.in/api/v2.2/admin/batches/");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTgsInVzZXJfaWQiOjE4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzMTEyNzl9.fDF03EIOEoXTyVUA3sN9-biUGhWrzO_NIZo1KYCUkbU");
request.AddParameter("application/json", "{\n    \"name\": \"Online Test Batch\"\n}", ParameterType.RequestBody);

IRestResponse response = client.Execute(request);
<?php

$request = new HttpRequest();
$request->setUrl('http://demo.testpress.in/api/v2.2/admin/batches/');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'postman-token' => 'd6cf4ce2-eb4b-272f-8f8d-165080a65d41',
  'cache-control' => 'no-cache',
  'authorization' => 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc',
  'content-type' => 'application/json'
));

$request->setBody('{
    "name": "Online Test Batch"
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
var http = require("http");

var options = {
  "method": "POST",
  "hostname": "demo.testpress.in",
  "port": null,
  "path": "/api/v2.2/admin/batches/",
  "headers": {
    "content-type": "application/json",
    "authorization": "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc",
    "cache-control": "no-cache",
    "postman-token": "4428c61c-5276-290f-164d-9d817c1428bf"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ name: 'Online Test Batch' }));
req.end();
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"name\": \"Online Test Batch\"\n}");
Request request = new Request.Builder()
  .url("http://demo.testpress.in/api/v2.2/admin/batches/")
  .post(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc")
  .addHeader("cache-control", "no-cache")
  .addHeader("postman-token", "9d0d627c-b0fc-833f-0c24-c15da1278f82")
  .build();

Response response = client.newCall(request).execute();
package main

import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "http://demo.testpress.in/api/v2.2/admin/batches/"

    payload := strings.NewReader("{\n    \"name\": \"Online Test Batch\"\n}")

    req, _ := http.NewRequest("POST", url, payload)

    req.Header.Add("content-type", "application/json")
    req.Header.Add("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc")
    req.Header.Add("cache-control", "no-cache")
    req.Header.Add("postman-token", "447f5740-7bc0-1d00-5b14-7f5f9e75cb95")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}

The above command returns JSON structured like this:

{
    "id": 28, 
    "name": "Online Test Batch", 
    "url": "http://demo.testbench.in:8000/api/v2.2/admin/batches/28/"
} 

This endpoint creates a new batch in your institute

HTTP Request

POST /api/v2.2/admin/batches/

Response Fields

Name Type Description
id int Unique ID for the created Batch
name string Batch’s Name
url string URL to get details of the batch

Posts

Posts are broadcast data which the institutes want to share to their users. This endpoint can be used to retrieve the posts created in your institute

Get all posts

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/admin/posts/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/admin/posts/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'content-type': "application/json",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/admin/posts/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json'
var client = new RestClient("http://demo.testpress.in/api/v2.2/admin/posts/");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw");
IRestResponse response = client.Execute(request);

The above command returns JSON structured like this:

{
    "count": 2, 
    "next": null, 
    "previous": null, 
    "per_page": 20, 
    "results": [
        {
            "url": "http://demo.testpress.in/api/v2.2/admin/posts/sbbj-recruitment-20152016-sbbjbankcom-various-jobs-advt-apply-online/", 
            "created_by": {
                "id": 16, 
                "url": "http://demo.testpress.in/api/v2.2/users/16/", 
                "username": "bharath", 
                "display_name": "Bharath Kumar S", 
                "first_name": "Bharath Kumar", 
                "last_name": "S", 
                "photo": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/cb88287098924bd6ae615ca4aa71eab5.png", 
                "large_image": "", 
                "medium_image": "", 
                "small_image": "", 
                "x_small_image": "", 
                "mini_image": "", 
                "state": "", 
                "state_code": "", 
                "gender": "Male", 
                "gender_code": "male"
            }, 
            "category": {
                "id": 1, 
                "name": "Alerts", 
                "color": "FF0000", 
                "slug": "alerts", 
                "is_starred": false
            }, 
            "created": "2015-09-24T10:00:16.609Z", 
            "modified": "2016-06-04T16:09:59.446Z", 
            "id": 1, 
            "is_active": true, 
            "title": "SBBJ Recruitment 2015\u20132016 sbbjbank.com Various Jobs Advt Apply Online", 
            "summary": "SBBJ Recruitment 2015\u20132016 sbbjbank.com Various Jobs Advt Apply Online\r\n", 
            "batches": [
                {
                    "id": 17, 
                    "name": "ECE", 
                    "url": "http://demo.testpress.in/api/v2.2/admin/batches/17/"
                }, 
                {
                    "id": 16, 
                    "name": "EEE", 
                    "url": "http://demo.testpress.in/api/v2.2/admin/batches/16/"
                }
            ], 
            "products": [], 
            "is_public": false, 
            "published_date": "2016-06-04T16:09:59.431Z"
        }, 
        {
            "url": "http://demo.testpress.in/api/v2.2/admin/posts/sbi-recruitment-2015-2016-wwwsbicoin-manager-job-notification-online/", 
            "created_by": {
                "id": 16, 
                "url": "http://demo.testpress.in/api/v2.2/users/16/", 
                "username": "bharath", 
                "display_name": "Bharath Kumar S", 
                "first_name": "Bharath Kumar", 
                "last_name": "S", 
                "photo": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/cb88287098924bd6ae615ca4aa71eab5.png", 
                "large_image": "", 
                "medium_image": "", 
                "small_image": "", 
                "x_small_image": "", 
                "mini_image": "", 
                "state": "", 
                "state_code": "", 
                "gender": "Male", 
                "gender_code": "male"
            }, 
            "category": {
                "id": 1, 
                "name": "Alerts", 
                "color": "FF0000", 
                "slug": "alerts", 
                "is_starred": false
            }, 
            "created": "2015-09-24T13:45:38.374Z", 
            "modified": "2016-06-04T16:09:59.664Z", 
            "id": 2, 
            "is_active": true, 
            "title": "SBI Recruitment 2015-2016 www.sbi.co.in Manager Job Notification Online", 
            "summary": "State Bank of India has unfolded a job notification of SBI Recruitment. Organization requires confident and responsible contenders for filling up the vacancies of Deputy General Manager (Law) Post....", 
            "batches": [
                {
                    "id": 17, 
                    "name": "ECE", 
                    "url": "http://demo.testpress.in/api/v2.2/admin/batches/17/"
                }, 
                {
                    "id": 16, 
                    "name": "EEE", 
                    "url": "http://demo.testpress.in/api/v2.2/admin/batches/16/"
                }
            ], 
            "products": [], 
            "is_public": false, 
            "published_date": "2016-06-04T16:09:59.656Z"
        }
    ]
}

This endpoint retrieves all posts created by your institute admins

HTTP Request

GET /api/v2.2/admin/posts/

Get single post

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/admin/posts/working-great/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw'
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'

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

url = "http://demo.testpress.in/api/v2.2/admin/posts/working-great/"

headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw",
    'content-type': "application/json",
    'cache-control': "no-cache"
    }

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

print(response.text)
curl --request GET \
  --url http://demo.testpress.in/api/v2.2/admin/posts/working-great/ \
  --header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json'
var client = new RestClient("http://demo.testpress.in/api/v2.2/admin/posts/working-great/");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw");
IRestResponse response = client.Execute(request);

The above command returns JSON structured like this:

{
  "url": "http://demo.testpress.in/api/v2.2/posts/working-great/",
  "created_by": {
    "id": 10,
    "url": "http://demo.testpress.in/api/v2.2/users/10/",
    "username": "admin",
    "display_name": "admin",
    "first_name": "",
    "last_name": "",
    "photo": "",
    "large_image": "",
    "medium_image": "",
    "small_image": "",
    "x_small_image": "",
    "mini_image": ""
  },
  "category": {
    "id": 2,
    "name": "Daliy News",
    "color": "33CC33",
    "slug": "daliy-news"
  },
  "created": "2.25-10-07T06:00:07Z",
  "modified": "2.25-10-07T06:00:07Z",
  "id": 26,
  "active": true,
  "title": "Working Great",
  "summary": "All is Well",
  "content_html": "<p>Good Better Best</p>",
  "institute": 1
}

This endpoint retrieves a single post.

HTTP Request

GET /api/v2.2/posts/<slug>

URL Parameters

Parameter Description
slug The unique slug of the post to retrieve

Create a post

re 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/admin/posts/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE'
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request["postman-token"] = '653bbc93-696f-e194-caa5-21b5e2a736b7'
request.body = "{\n    \"title\": \"NCRA Recruitment 2015 www.ncra.tifr.res.in JRF Vacancies Apply Online\", \n    \"summary\": \"Test Summary\", \n    \"content_html\": \"<h2><strong>NCRA Recruitment</strong></h2> <p>National Centre for Radio Astrophysics, Pune has emitted an advertisement related to <strong>NCRA Recruitment</strong>. The organization is willing to hire self-motivated and expert candidates against vacancies of Junior Research Fellow (JRF) Post. Job Seekers who fulfill the eligibility criteria can apply against NCRA Recruitment 2015 by following online process. Job seekers who are eagerly waiting for jobs in this organization may apply against these Openings as soon as possible. Aspirants need to submit application form in proper manner on or prior to end date that is represented below.</p>\", \n    \"batches\": [\n        \"Online Test Batch\"\n    ], \n    \"products\": [\n        \"IAS Prelims Power Pack\"\n    ], \n    \"is_public\": false, \n    \"category\": \"Alerts\", \n    \"published_date\": \"2016-08-05T09:17:56.883Z\"\n}"

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

url = "http://demo.testpress.in/api/v2.2/admin/posts/"

payload = "{\n    \"title\": \"NCRA Recruitment 2015 www.ncra.tifr.res.in JRF Vacancies Apply Online\", \n    \"summary\": \"Test Summary\", \n    \"content_html\": \"<h2><strong>NCRA Recruitment</strong></h2> <p>National Centre for Radio Astrophysics, Pune has emitted an advertisement related to <strong>NCRA Recruitment</strong>. The organization is willing to hire self-motivated and expert candidates against vacancies of Junior Research Fellow (JRF) Post. Job Seekers who fulfill the eligibility criteria can apply against NCRA Recruitment 2015 by following online process. Job seekers who are eagerly waiting for jobs in this organization may apply against these Openings as soon as possible. Aspirants need to submit application form in proper manner on or prior to end date that is represented below.</p>\", \n    \"batches\": [\n        \"Online Test Batch\"\n    ], \n    \"products\": [\n        \"IAS Prelims Power Pack\"\n    ], \n    \"is_public\": false, \n    \"category\": \"Alerts\", \n    \"published_date\": \"2016-08-05T09:17:56.883Z\"\n}"
headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE",
    'content-type': "application/json",
    'cache-control': "no-cache",
    'postman-token': "8a880552-d0f7-f2f8-be8f-dab095c4f24c"
    }

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

print(response.text)
curl -X POST -H "Authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -H "Postman-Token: ababd89e-d515-7bca-b2a5-2a99a5a15d6d" -d '{
    "title": "NCRA Recruitment 2015 www.ncra.tifr.res.in JRF Vacancies Apply Online", 
    "summary": "Test Summary", 
    "content_html": "<h2><strong>NCRA Recruitment</strong></h2> <p>National Centre for Radio Astrophysics, Pune has emitted an advertisement related to <strong>NCRA Recruitment</strong>. The organization is willing to hire self-motivated and expert candidates against vacancies of Junior Research Fellow (JRF) Post. Job Seekers who fulfill the eligibility criteria can apply against NCRA Recruitment 2015 by following online process. Job seekers who are eagerly waiting for jobs in this organization may apply against these Openings as soon as possible. Aspirants need to submit application form in proper manner on or prior to end date that is represented below.</p>", 
    "batches": [
        "Online Test Batch"
    ], 
    "products": [
        "IAS Prelims Power Pack"
    ], 
    "is_public": false, 
    "category": "Alerts", 
    "published_date": "2016-08-05T09:17:56.883Z"
}' "http://demo.testpress.in/api/v2.2/admin/posts/"
var client = new RestClient("http://demo.testpress.in/api/v2.2/admin/posts/");
var request = new RestRequest(Method.POST);
request.AddHeader("postman-token", "e837fb2b-c7c2-c3de-f9ba-d05fc084da77");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE");
request.AddParameter("application/json", "{\n    \"title\": \"NCRA Recruitment 2015 www.ncra.tifr.res.in JRF Vacancies Apply Online\", \n    \"summary\": \"Test Summary\", \n    \"content_html\": \"<h2><strong>NCRA Recruitment</strong></h2> <p>National Centre for Radio Astrophysics, Pune has emitted an advertisement related to <strong>NCRA Recruitment</strong>. The organization is willing to hire self-motivated and expert candidates against vacancies of Junior Research Fellow (JRF) Post. Job Seekers who fulfill the eligibility criteria can apply against NCRA Recruitment 2015 by following online process. Job seekers who are eagerly waiting for jobs in this organization may apply against these Openings as soon as possible. Aspirants need to submit application form in proper manner on or prior to end date that is represented below.</p>\", \n    \"batches\": [\n        \"Online Test Batch\"\n    ], \n    \"products\": [\n        \"IAS Prelims Power Pack\"\n    ], \n    \"is_public\": false, \n    \"category\": \"Alerts\", \n    \"published_date\": \"2016-08-05T09:17:56.883Z\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

The above command returns JSON structured like this:

{
  "url": "http://demo.testpress.in/api/v2.2/admin/posts/ncra-recruitment-2015-wwwncratifrresin-jrf-vacancies-apply-online-14/",
  "created_by": {
    "id": 38,
    "url": "http://demo.testpress.in/api/v2.2/users/38/",
    "username": "admin",
    "display_name": "admin",
    "first_name": "",
    "last_name": "",
    "photo": "",
    "large_image": "",
    "medium_image": "",
    "small_image": "",
    "x_small_image": "",
    "mini_image": ""
  },
  "category": {
    "id": 1,
    "name": "Alerts",
    "color": "FF0000",
    "slug": "alerts",
    "is_starred": false
  },
  "created": "2016-08-05T11:56:55.902Z",
  "modified": "2016-08-05T11:56:55.940Z",
  "id": 116,
  "is_active": true,
  "title": "NCRA Recruitment 2015 www.ncra.tifr.res.in JRF Vacancies Apply Online",
  "summary": "Test Summary",
  "batches": [
    {
      "id": 34,
      "name": "Online Test Batch",
      "url": "http://demo.testpress.in/api/v2.2/admin/batches/34/"
    }
  ],
  "products": [
    {
      "id": 5,
      "url": "http://demo.testpress.in/api/v2.2/products/ias-prelims-power-pack/",
      "title": "IAS Prelims Power Pack",
      "slug": "ias-prelims-power-pack",
      "image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/c098795970e64bbab0265e82c4a40f6a.png",
      "images": [
        {
          "original": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/c098795970e64bbab0265e82c4a40f6a.png",
          "medium": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/2c5648e2884e481aa4256554ad601d66.png",
          "small": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/a36d18c340c84e8eaa24d17697b1cb88.png"
        }
      ],
      "start_date": "2015-01-01T00:00:00+05:30",
      "end_date": "2019-01-01T00:00:00+05:30",
      "categories": [
        "TNPSC"
      ],
      "types": [
        "Exams",
        "Books"
      ],
      "exams_count": 1,
      "notes_count": 4,
      "price": "1.00"
    }
  ],
  "is_public": false,
  "published_date": "2016-08-05T09:17:56.883Z"
}

This endpoint creates a post for a batch / product in the given category

HTTP Request

POST /api/v2.2/admin/posts/

Fields

Name Type Description
url string Unique URL for the Post. This URL will be used to update / delete the post
title string Post Title
summary string Summary of post
content_html string Content of the post
batches array of strings Pass as array of batch name strings.
products array of strings Pass as array of product name strings
is_public Boolean Is this a public post. True or False
category string Category of the post.

Update a post

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/admin/posts/sbbj-recruitment/")

http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Get.new(url)
    request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE'
    request["content-type"] = 'application/json'
    request["cache-control"] = 'no-cache'
    request["postman-token"] = 'd7fcb574-2dc2-1d08-6dab-439e09db2028'
    request.body = "{\n    \"title\": \"NCRA Recruitment 2015 www.ncra.tifr.res.in JRF Vacancies Apply Online\", \n    \"summary\": \"Test Summary\", \n    \"content_html\": \"<h2><strong>NCRA Recruitment</strong></h2> <p>National Centre for Radio Astrophysics, Pune has emitted an advertisement related to <strong>NCRA Recruitment</strong>. The organization is willing to hire self-motivated and expert candidates against vacancies of Junior Research Fellow (JRF) Post. Job Seekers who fulfill the eligibility criteria can apply against NCRA Recruitment 2015 by following online process. Job seekers who are eagerly waiting for jobs in this organization may apply against these Openings as soon as possible. Aspirants need to submit application form in proper manner on or prior to end date that is represented below.</p>\", \n    \"batches\": [\n        \"Online Test Batch\"\n    ], \n    \"products\": [\n        \"IAS Prelims Power Pack\"\n    ], \n    \"is_public\": false, \n    \"category\": \"Alerts\"\n}"

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

url = "http://demo.testpress.in/api/v2.2/admin/posts/sbbj-recruitment/"

payload = "{\n    \"title\": \"NCRA Recruitment 2015 www.ncra.tifr.res.in JRF Vacancies Apply Online\", \n    \"summary\": \"Test Summary\", \n    \"content_html\": \"<h2><strong>NCRA Recruitment</strong></h2> <p>National Centre for Radio Astrophysics, Pune has emitted an advertisement related to <strong>NCRA Recruitment</strong>. The organization is willing to hire self-motivated and expert candidates against vacancies of Junior Research Fellow (JRF) Post. Job Seekers who fulfill the eligibility criteria can apply against NCRA Recruitment 2015 by following online process. Job seekers who are eagerly waiting for jobs in this organization may apply against these Openings as soon as possible. Aspirants need to submit application form in proper manner on or prior to end date that is represented below.</p>\", \n    \"batches\": [\n        \"Online Test Batch\"\n    ], \n    \"products\": [\n        \"IAS Prelims Power Pack\"\n    ], \n    \"is_public\": false, \n    \"category\": \"Alerts\"\n}"
headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE",
    'content-type': "application/json",
    'cache-control': "no-cache",
    'postman-token': "6e281fee-24ba-df8a-190a-ee86fc01ea11"
    }

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

print(response.text)
curl -X GET -H "Authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -H "Postman-Token: 885de78c-74d5-77d3-4da7-751d4020d920" "http://demo.testpress.in/api/v2.2/admin/posts/sbbj-recruitment/"
var client = new RestClient("http://demo.testpress.in/api/v2.2/admin/posts/sbbj-recruitment/");
var request = new RestRequest(Method.GET);
request.AddHeader("postman-token", "a94cd285-075e-1b51-eac6-7af44424bf1f");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE");
request.AddParameter("application/json", "{\n    \"title\": \"NCRA Recruitment 2015 www.ncra.tifr.res.in JRF Vacancies Apply Online\", \n    \"summary\": \"Test Summary\", \n    \"content_html\": \"<h2><strong>NCRA Recruitment</strong></h2> <p>National Centre for Radio Astrophysics, Pune has emitted an advertisement related to <strong>NCRA Recruitment</strong>. The organization is willing to hire self-motivated and expert candidates against vacancies of Junior Research Fellow (JRF) Post. Job Seekers who fulfill the eligibility criteria can apply against NCRA Recruitment 2015 by following online process. Job seekers who are eagerly waiting for jobs in this organization may apply against these Openings as soon as possible. Aspirants need to submit application form in proper manner on or prior to end date that is represented below.</p>\", \n    \"batches\": [\n        \"Online Test Batch\"\n    ], \n    \"products\": [\n        \"IAS Prelims Power Pack\"\n    ], \n    \"is_public\": false, \n    \"category\": \"Alerts\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

The above command returns JSON structured like this:

{
  "url": "http://demo.testpress.in/api/v2.2/admin/posts/sbbj-recruitment/",
  "created_by": {
      "id": 38,
      "url": "http://demo.testpress.in/api/v2.2/users/38/",
      "username": "admin",
      "display_name": "admin",
      "first_name": "",
      "last_name": "",
      "photo": "",
      "large_image": "",
      "medium_image": "",
      "small_image": "",
      "x_small_image": "",
      "mini_image": ""
    },
  "category": {
      "id": 1,
      "name": "Alerts",
      "color": "FF0000",
      "slug": "alerts",
      "is_starred": false
    },
  "created": "2015-10-06T08:51:02.327Z",
  "modified": "2016-08-12T13:23:00.959Z",
  "id": 26,
  "is_active": true,
  "title": "NCRA Recruitment 2015 www.ncra.tifr.res.in JRF Vacancies Apply Online",
  "summary": "Test Summary",
  "content_html": "<h2><strong>NCRA Recruitment</strong></h2> <p>National Centre for Radio Astrophysics, Pune has emitted an advertisement related to <strong>NCRA Recruitment</strong>. The organization is willing to hire self-motivated and expert candidates against vacancies of Junior Research Fellow (JRF) Post. Job Seekers who fulfill the eligibility criteria can apply against NCRA Recruitment 2015 by following online process. Job seekers who are eagerly waiting for jobs in this organization may apply against these Openings as soon as possible. Aspirants need to submit application form in proper manner on or prior to end date that is represented below.</p>",
  "batches": [
          {
                "id": 34,
                "name": "Online Test Batch",
                "url": "http://demo.testpress.in/api/v2.2/admin/batches/34/"
              }
    ],
  "products": [
          {
                "id": 5,
                "url": "http://demo.testpress.in/api/v2.2/products/ias-prelims-power-pack/",
                "title": "IAS Prelims Power Pack",
                "slug": "ias-prelims-power-pack",
                "image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/c098795970e64bbab0265e82c4a40f6a.png",
                "images": [
                            {
                                      "original": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/c098795970e64bbab0265e82c4a40f6a.png",
                                      "medium": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/2c5648e2884e481aa4256554ad601d66.png",
                                      "small": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/a36d18c340c84e8eaa24d17697b1cb88.png"
                                    }
                      ],
                "start_date": "2015-01-01T00:00:00+05:30",
                "end_date": "2019-01-01T00:00:00+05:30",
                "categories": [
                            "TNPSC"
                                  ],
                "types": [
                            "Exams",
                        "Books"
                                  ],
                "exams_count": 1,
                "notes_count": 4,
                "price": "1.00"
              }
      ],
  "is_public": false,
  "published_date": "2015-10-06T08:51:02Z"
}}

This endpoint updates details of the post with the given URL.

HTTP Request

PUT /api/v2.2/admin/posts/sbbj-recruitment/

Fields

Name Type Description
url string Unique URL for the Post
title string Post Title
summary string Summary of post
content_html string Content of the post
batches array of strings Pass as array of batch name strings.
products array of strings Pass as array of product name strings
is_public Boolean Is this a public post. True or False
category string Category of the post.

Delete a post

require 'uri'
require 'net/http'

url = URI("http://demo.testpress.in/api/v2.2/admin/posts/expected-questions-seating-arrangements/")

http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Delete.new(url)
    request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE'
    request["content-type"] = 'application/json'
    request["cache-control"] = 'no-cache'
    request["postman-token"] = 'ab37c7db-8ff8-38dc-569a-70b64f4a4924'
    request.body = "{\n    \"title\": \"NCRA Recruitment 2015 www.ncra.tifr.res.in JRF Vacancies Apply Online\", \n    \"summary\": \"Test Summary\", \n    \"content_html\": \"<h2><strong>NCRA Recruitment</strong></h2> <p>National Centre for Radio Astrophysics, Pune has emitted an advertisement related to <strong>NCRA Recruitment</strong>. The organization is willing to hire self-motivated and expert candidates against vacancies of Junior Research Fellow (JRF) Post. Job Seekers who fulfill the eligibility criteria can apply against NCRA Recruitment 2015 by following online process. Job seekers who are eagerly waiting for jobs in this organization may apply against these Openings as soon as possible. Aspirants need to submit application form in proper manner on or prior to end date that is represented below.</p>\", \n    \"batches\": [\n        \"Online Test Batch\"\n    ], \n    \"products\": [\n        \"IAS Prelims Power Pack\"\n    ], \n    \"is_public\": false, \n    \"category\": \"Alerts\"\n}"

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

url = "http://demo.testpress.in/api/v2.2/admin/posts/expected-questions-seating-arrangements/"

payload = "{\n    \"title\": \"NCRA Recruitment 2015 www.ncra.tifr.res.in JRF Vacancies Apply Online\", \n    \"summary\": \"Test Summary\", \n    \"content_html\": \"<h2><strong>NCRA Recruitment</strong></h2> <p>National Centre for Radio Astrophysics, Pune has emitted an advertisement related to <strong>NCRA Recruitment</strong>. The organization is willing to hire self-motivated and expert candidates against vacancies of Junior Research Fellow (JRF) Post. Job Seekers who fulfill the eligibility criteria can apply against NCRA Recruitment 2015 by following online process. Job seekers who are eagerly waiting for jobs in this organization may apply against these Openings as soon as possible. Aspirants need to submit application form in proper manner on or prior to end date that is represented below.</p>\", \n    \"batches\": [\n        \"Online Test Batch\"\n    ], \n    \"products\": [\n        \"IAS Prelims Power Pack\"\n    ], \n    \"is_public\": false, \n    \"category\": \"Alerts\"\n}"
headers = {
    'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE",
    'content-type': "application/json",
    'cache-control': "no-cache",
    'postman-token': "3f7d048c-5c4b-3727-cce5-c592f2809dd2"
    }

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

print(response.text)
curl -X DELETE -H "Authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -H "Postman-Token: 2cfea85b-fc7d-c378-8151-4a1731d1fd5e" -d '{
    "title": "NCRA Recruitment 2015 www.ncra.tifr.res.in JRF Vacancies Apply Online", 
    "summary": "Test Summary", 
    "content_html": "<h2><strong>NCRA Recruitment</strong></h2> <p>National Centre for Radio Astrophysics, Pune has emitted an advertisement related to <strong>NCRA Recruitment</strong>. The organization is willing to hire self-motivated and expert candidates against vacancies of Junior Research Fellow (JRF) Post. Job Seekers who fulfill the eligibility criteria can apply against NCRA Recruitment 2015 by following online process. Job seekers who are eagerly waiting for jobs in this organization may apply against these Openings as soon as possible. Aspirants need to submit application form in proper manner on or prior to end date that is represented below.</p>", 
    "batches": [
                "Online Test Batch"
                    ], 
    "products": [
                "IAS Prelims Power Pack"
                    ], 
    "is_public": false, 
    "category": "Alerts"
}' "http://demo.testpress.in/api/v2.2/admin/posts/expected-questions-seating-arrangements/"''''

var client = new RestClient("http://demo.testpress.in/api/v2.2/admin/posts/expected-questions-seating-arrangements/");
var request = new RestRequest(Method.DELETE);
request.AddHeader("postman-token", "6b21d4e8-efa5-7b5b-c798-662e39a3f13b");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE");
request.AddParameter("application/json", "{\n    \"title\": \"NCRA Recruitment 2015 www.ncra.tifr.res.in JRF Vacancies Apply Online\", \n    \"summary\": \"Test Summary\", \n    \"content_html\": \"<h2><strong>NCRA Recruitment</strong></h2> <p>National Centre for Radio Astrophysics, Pune has emitted an advertisement related to <strong>NCRA Recruitment</strong>. The organization is willing to hire self-motivated and expert candidates against vacancies of Junior Research Fellow (JRF) Post. Job Seekers who fulfill the eligibility criteria can apply against NCRA Recruitment 2015 by following online process. Job seekers who are eagerly waiting for jobs in this organization may apply against these Openings as soon as possible. Aspirants need to submit application form in proper manner on or prior to end date that is represented below.</p>\", \n    \"batches\": [\n        \"Online Test Batch\"\n    ], \n    \"products\": [\n        \"IAS Prelims Power Pack\"\n    ], \n    \"is_public\": false, \n    \"category\": \"Alerts\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

The above command returns with status 204

This endpoint delete a post with the given URL.

HTTP Request

DELETE /api/v2.2/admin/posts/expected-questions-seating-arrangements/

Errors

The Kittn API uses the following error codes:

Error Code Meaning
400 Bad Request – Your request sucks
401 Unauthorized – Your API key is wrong
403 Forbidden – The kitten requested is hidden for administrators only
404 Not Found – The specified kitten could not be found
405 Method Not Allowed – You tried to access a kitten with an invalid method
406 Not Acceptable – You requested a format that isn’t json
410 Gone – The kitten requested has been removed from our servers
418 I’m a teapot
429 Too Many Requests – You’re requesting too many kittens! Slow down!
500 Internal Server Error – We had a problem with our server. Try again later.
503 Service Unavailable – We’re temporarially offline for maintanance. Please try again later.