First Request
Objective
In this guide, you will make your first successful request to the Pontotel API: list users.
What you'll do
- Authenticate and obtain token
- Make GET request to list users
- Process the response
Step 1: Authentication
First, obtain your access token:
| Python |
|---|
| import requests
# Login endpoint
login_url = "https://apis.pontotel.com.br/pontotel/api/v4/login/"
# Credentials
credentials = {
"username": "your_username",
"password": "your_password"
}
# Login
response = requests.post(login_url, json=credentials)
if response.status_code == 200:
data = response.json()
access_token = data["access_token"]
print(f"✅ Token obtained: {access_token[:20]}...")
else:
print(f"❌ Login error: {response.status_code}")
print(response.json())
|
| JavaScript |
|---|
| const loginUrl = "https://apis.pontotel.com.br/pontotel/api/v4/login/";
const credentials = {
username: "your_username",
password: "your_password"
};
const loginResponse = await fetch(loginUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(credentials)
});
if (loginResponse.ok) {
const data = await loginResponse.json();
const accessToken = data.access_token;
console.log('✅ Token obtained:', accessToken.substring(0, 20) + '...');
} else {
console.error('❌ Login error:', loginResponse.status);
}
|
| Bash |
|---|
| curl -X POST "https://apis.pontotel.com.br/pontotel/api/v4/login/" \
-H "Content-Type: application/json" \
-d '{
"username": "your_username",
"password": "your_password"
}' \
-o response.json
# Extract token
TOKEN=$(cat response.json | jq -r '.access_token')
echo "✅ Token obtained: ${TOKEN:0:20}..."
|
Step 2: List Users
Now use the token to make your first request:
Step 3: Understand the Response
The response will be in this format:
| JSON |
|---|
| {
"count": 150,
"next": "https://apis.pontotel.com.br/pontotel/api/v4/usuarios/?page=2",
"previous": null,
"results": [
{
"id": 1,
"username": "user1",
"email": "user1@example.com",
"first_name": "John",
"last_name": "Smith",
"is_active": true,
"date_joined": "2025-01-01T10:00:00Z"
}
]
}
|
Response Fields
| Field | Description |
count | Total available records |
next | URL for next page (null if none) |
previous | URL for previous page (null if none) |
results | Array with current page data |
Complete Script
Here is the complete code to copy and test:
Possible Errors
| Error | Cause | Solution |
| 401 Unauthorized | Invalid or expired token | Login again |
| 403 Forbidden | No permission to access users | Check user permissions |
| 429 Too Many Requests | Too many requests | Implement rate limiting |
| 500 Internal Server Error | Server error | Try again or contact support |
Next Steps
Congratulations! 🎉 You made your first request successfully.
Now explore more:
- Understand pagination →
- Learn about other entities →
- Create a user →
- See advanced examples →