Language Examples

C#

Get Example


string url = "https://vpic.nhtsa.dot.gov/api/vehicles/GetModelsForMakeId/440?format=json";
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(url);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
try
{
	var tmp = client.GetAsync(url).Result;
	if (tmp.IsSuccessStatusCode)
		var result = tmp.Content.ReadAsStringAsync();
}
catch (Exception err)
{
	// error handling
}
			

Post Example


string text = "3GNDA13D76S000000;5XYKT3A12CG000000;";
string url = @"https://vpic.nhtsa.dot.gov/api/vehicles/DecodeVINValuesBatch/";
var nameValues = new Dictionary<string, string>();
nameValues.Add("data", text);
nameValues.Add("format", "json");
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(url);
		
// using FormUrlEncodedContent
var name = new FormUrlEncodedContent(nameValues);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
System.Threading.CancellationToken token = new System.Threading.CancellationToken();
try
{
	var tmp = client.PostAsync(client.BaseAddress, name, token).Result;
	var result = tmp.Content.ReadAsStringAsync();
}
catch (Exception err)
{
	// error handling
}
		

VB.NET

Javascript with jQuery

PHP

Python

Ruby

R