> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://partner.ninjatrader.com/connect/overview/quick-setup/first-api-call/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://partner.ninjatrader.com/_mcp/server. # Your First API Call This guide walks you through making your first successful API call to the NinjaTrader Partner API, covering authentication, request structure, and response handling. ## Prerequisites Before making your first API call, ensure you have: * ✅ **Partner API credentials** (API key and secret) * ✅ **Development environment** set up * ✅ **HTTP client** ready (curl, Postman, or code library) If you haven't completed these steps, start with our [5-Minute Quickstart](/overview/quick-setup/5-minute-quickstart). ## Step 1: Authenticate and Get Access Token All API requests require a valid access token. Here's how to obtain one: ### Request POST [https://demo.tradovateapi.com/v1/auth/accesstokenrequest](https://demo.tradovateapi.com/v1/auth/accesstokenrequest) ```curl curl -X POST https://demo.tradovateapi.com/v1/auth/accesstokenrequest \ -H "Content-Type: application/json" \ -d '{ "name": "string", "password": "string" }' ``` ```python import requests url = "https://demo.tradovateapi.com/v1/auth/accesstokenrequest" payload = { "name": "string", "password": "string" } headers = {"Content-Type": "application/json"} response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://demo.tradovateapi.com/v1/auth/accesstokenrequest'; const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"name":"string","password":"string"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://demo.tradovateapi.com/v1/auth/accesstokenrequest" payload := strings.NewReader("{\n \"name\": \"string\",\n \"password\": \"string\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://demo.tradovateapi.com/v1/auth/accesstokenrequest") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = 'application/json' request.body = "{\n \"name\": \"string\",\n \"password\": \"string\"\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://demo.tradovateapi.com/v1/auth/accesstokenrequest") .header("Content-Type", "application/json") .body("{\n \"name\": \"string\",\n \"password\": \"string\"\n}") .asString(); ``` ```php request('POST', 'https://demo.tradovateapi.com/v1/auth/accesstokenrequest', [ 'body' => '{ "name": "string", "password": "string" }', 'headers' => [ 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://demo.tradovateapi.com/v1/auth/accesstokenrequest"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"name\": \"string\",\n \"password\": \"string\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Content-Type": "application/json"] let parameters = [ "name": "string", "password": "string" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://demo.tradovateapi.com/v1/auth/accesstokenrequest")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response (200) ```json { "errorText": "string", "hibpHint": "EmailAndPasswordCompromised", "accessToken": "string", "expirationTime": "2024-01-15T09:30:00Z", "passwordExpirationTime": "2024-01-15T09:30:00Z", "userStatus": "Active", "userId": 1, "name": "string", "hasLive": true, "hasSimPlus": true, "showKIDs": true } ``` If you're unfamiliar with authentication, please read the [Auth Overview](/overview/quick-setup/auth-overview) section. ## Step 2: Make Your First Data Request Now let's retrieve your user profile information: ### Request GET [https://demo.tradovateapi.com/v1/auth/me](https://demo.tradovateapi.com/v1/auth/me) ```curl curl https://demo.tradovateapi.com/v1/auth/me \ -H "Authorization: Bearer " ``` ```python import requests url = "https://demo.tradovateapi.com/v1/auth/me" headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers) print(response.json()) ``` ```javascript const url = 'https://demo.tradovateapi.com/v1/auth/me'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://demo.tradovateapi.com/v1/auth/me" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://demo.tradovateapi.com/v1/auth/me") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://demo.tradovateapi.com/v1/auth/me") .header("Authorization", "Bearer ") .asString(); ``` ```php request('GET', 'https://demo.tradovateapi.com/v1/auth/me', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://demo.tradovateapi.com/v1/auth/me"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://demo.tradovateapi.com/v1/auth/me")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response (200) ```json { "errorText": "string", "userId": 1, "name": "string", "fullName": "string", "email": "string", "emailVerified": true, "isTrial": true, "organizationName": "string", "currentAccountPlan": "string", "currentMDSubs": [ "string" ], "currentBalance": 1.1, "activePlugins": [ "string" ], "isMasterAccountOwner": true } ```