Skip to content

First Request

Objective

In this guide, you will make your first successful request to the Pontotel API: list shifts.

What you'll do

  1. Authenticate and obtain a token
  2. Send a GET request to list shifts
  3. 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"
}

# Log in
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 shifts

Now use the token to make your first request:

Python
# Shifts endpoint
jornadas_url = "https://apis.pontotel.com.br/pontotel/api/v4/jornadas/"

# Authenticated headers
headers = {
    "Authorization": f"Bearer {access_token}",
    "Content-Type": "application/json"
}

# Make request
response = requests.get(jornadas_url, headers=headers)

if response.status_code == 200:
    data = response.json()
    print(f"✅ Request successful!")
    print(f"Total shifts: {data['total']}")
    print(f"\nFirst 3 shifts:")
    for jornada in data['itens'][:3]:
        print(f"  - [{jornada['codigo']}] {jornada['nome']}")
else:
    print(f"❌ Request error: {response.status_code}")
JavaScript
const jornadasUrl = "https://apis.pontotel.com.br/pontotel/api/v4/jornadas/";

const headers = {
  'Authorization': `Bearer ${accessToken}`,
  'Content-Type': 'application/json'
};

const jornadasResponse = await fetch(jornadasUrl, { headers });

if (jornadasResponse.ok) {
  const data = await jornadasResponse.json();
  console.log('✅ Request successful!');
  console.log('Total shifts:', data.total);
  console.log('\nFirst 3 shifts:');
  data.itens.slice(0, 3).forEach(jornada => {
    console.log(`  - [${jornada.codigo}] ${jornada.nome}`);
  });
} else {
  console.error('❌ Request error:', jornadasResponse.status);
}
Bash
1
2
3
curl -X GET "https://apis.pontotel.com.br/pontotel/api/v4/jornadas/" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json"

Step 3: Understand the response

The response will be returned in this format:

JSON
{
  "itens": [
    {
      "id": "1d3fc7947bee78a5179720a",
      "codigo": "0001",
      "ehJornadaDeTrabalho": true,
      "nome": "jornada de trabalho 08h x 18h",
      "entrada": "08:00",
      "pausa": "12:00",
      "retorno": "13:00",
      "saida": "18:00",
      "duracaoLegal": null,
      "tipoPagamento": "extra",
      "temPresencaObrigatoria": true,
      "regraDeCalculo": null,
      "criadoEm": "2025-09-23T17:00:57.767000-03:00",
      "ultimaModificacaoEm": "2025-09-23T17:00:57.767000-03:00",
      "removidoEm": null,
      "deletado": false
    }
  ],
  "total": 239,
  "pagina": 0,
  "por_pagina": 1,
  "ordenacao": [],
  "filtros": []
}

Response fields

Field Description
itens Array with the items from the current page (in this case, shifts)
total Total number of available records
pagina Current page index (starts at 0)
por_pagina Number of items per page
ordenacao Applied sorting criteria
filtros Applied query filters

Complete script

Here is the complete code to copy and test:

Python
import requests

def primeira_requisicao():
    # 1. Login
    login_url = "https://apis.pontotel.com.br/pontotel/api/v4/login/"
    credentials = {
        "username": "your_username",
        "password": "your_password"
    }

    login_response = requests.post(login_url, json=credentials)
    login_response.raise_for_status()
    access_token = login_response.json()["access_token"]
    print(f"✅ Authenticated successfully!")

    # 2. List shifts
    jornadas_url = "https://apis.pontotel.com.br/pontotel/api/v4/jornadas/"
    headers = {"Authorization": f"Bearer {access_token}"}

    jornadas_response = requests.get(jornadas_url, headers=headers)
    jornadas_response.raise_for_status()
    data = jornadas_response.json()

    # 3. Show results
    print(f"\n📊 Total shifts: {data['total']}")
    print(f"📄 Shifts on this page: {len(data['itens'])}")
    print(f"\n📋 First shifts:")
    for jornada in data['itens'][:5]:
        tipo = "✅" if jornada['ehJornadaDeTrabalho'] else "🔄"
        print(f"  {tipo} [{jornada['codigo']}] {jornada['nome']:40} {jornada['entrada']} - {jornada['saida']}")

    return data

if __name__ == "__main__":
    try:
        primeira_requisicao()
    except requests.exceptions.HTTPError as e:
        print(f"❌ HTTP error: {e}")
    except Exception as e:
        print(f"❌ Error: {e}")
JavaScript
async function primeiraRequisicao() {
  try {
    // 1. Login
    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) {
      throw new Error(`Login failed: ${loginResponse.status}`);
    }

    const { access_token } = await loginResponse.json();
    console.log('✅ Authenticated successfully!');

    // 2. List shifts
    const jornadasUrl = "https://apis.pontotel.com.br/pontotel/api/v4/jornadas/";
    const jornadasResponse = await fetch(jornadasUrl, {
      headers: { 'Authorization': `Bearer ${access_token}` }
    });

    if (!jornadasResponse.ok) {
      throw new Error(`Request failed: ${jornadasResponse.status}`);
    }

    const data = await jornadasResponse.json();

    // 3. Show results
    console.log(`\n📊 Total shifts: ${data.total}`);
    console.log(`📄 Shifts on this page: ${data.itens.length}`);
    console.log('\n📋 First shifts:');
    data.itens.slice(0, 5).forEach(jornada => {
      const tipo = jornada.ehJornadaDeTrabalho ? '✅' : '🔄';
      console.log(`  ${tipo} [${jornada.codigo}] ${jornada.nome} - ${jornada.entrada} to ${jornada.saida}`);
    });

    return data;
  } catch (error) {
    console.error('❌ Error:', error.message);
  }
}

primeiraRequisicao();

Next Steps

Congratulations! You have made your first request successfully.

Now explore more: