SDKs & Libraries
We don't have official SDKs yet, but connecting is simple with standard HTTP libraries. Here's how to get started in your language.
Making requests
Use these libraries to call the API:
JavaScript / Node.js
// Using native fetch (Node.js 18+)
const response = await fetch('https://api.4nortes.app/api/v1/orders', {
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
})
// Using axios
import axios from 'axios'
const client = axios.create({
baseURL: 'https://api.4nortes.app/api/v1',
headers: {
'Authorization': `Bearer ${token}`,
},
})
const response = await client.get('/orders')
Python
import requests
# Using requests library
headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json',
}
response = requests.get(
'https://api.4nortes.app/api/v1/orders',
headers=headers
)
data = response.json()
PHP
// Using Guzzle
use GuzzleHttp\Client;
$client = new Client([
'base_uri' => 'https://api.4nortes.app/api/v1/',
'headers' => [
'Authorization' => 'Bearer ' . $token,
'Content-Type' => 'application/json',
],
]);
$response = $client->get('orders');
$data = json_decode($response->getBody(), true);
Ruby
require 'net/http'
require 'json'
uri = URI('https://api.4nortes.app/api/v1/orders')
request = Net::HTTP::Get.new(uri)
request['Authorization'] = "Bearer #{token}"
request['Content-Type'] = 'application/json'
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
data = JSON.parse(response.body)
Build a simple wrapper
Here's a JavaScript helper class you can copy into your project:
class NextDayAPI {
constructor(token) {
this.token = token
this.baseUrl = 'https://api.4nortes.app/api/v1'
}
async request(method, endpoint, data = null) {
const options = {
method,
headers: {
'Authorization': `Bearer ${this.token}`,
'Content-Type': 'application/json',
},
}
if (data) {
options.body = JSON.stringify(data)
}
const response = await fetch(`${this.baseUrl}${endpoint}`, options)
const result = await response.json()
if (!result.success) {
throw new Error(result.message)
}
return result.data
}
// Orders
async createOrder(orderData) {
return this.request('POST', '/orders/create', orderData)
}
async getOrder(trackingNumber) {
return this.request('GET', `/orders/${trackingNumber}`)
}
async listOrders(params = {}) {
const query = new URLSearchParams(params).toString()
return this.request('GET', `/orders?${query}`)
}
async cancelOrder(trackingNumber) {
return this.request('POST', `/orders/${trackingNumber}/cancel`)
}
// Tracking
async track(trackingNumber) {
return this.request('GET', `/tracking/${trackingNumber}`)
}
// Quotes
async getQuote(quoteData) {
return this.request('POST', '/orders/quote', quoteData)
}
// Reference data
async getRegions() {
return this.request('GET', '/regions')
}
async getLocalities() {
return this.request('GET', '/localities')
}
async getServices() {
return this.request('GET', '/services')
}
}
// Usage - use the token provided by your NextDay administrator
const api = new NextDayAPI('your-token-here')
const order = await api.createOrder({
sender_name: 'My Store',
sender_phone: '+56912345678',
recipient_name: 'Jane Doe',
destination_address: 'Calle Principal 123',
destination_locality: 'Providencia',
})
console.log(`Created order: ${order.tracking_number}`)
Community libraries
Built something for 4N NextDay? Let us know and we'll list it here.
Check that any third-party library is up to date before using it.
Full API docs
For all the details:
- Orders API - Sync orders and download labels
- Tracking API - Fetch tracking for customers
- Rates API - Show shipping costs at checkout
- References API - Get regions, comunas, and services