About

The Peks customer API allows you to place orders with a REST API. The base url of the api is https://api.peks.nl/api/. There are currently three functions:

  1. /order/postcodes/
  2. /order/create/
  3. /order/possible/


The function /order/postcodes/ retrieves a list of all postcodes in which we deliver orders. With /order/create/ you can create an order. /order/possible/ accepts two locations (locations are defined as a postcode and housenumber), and checks if it's possible to do a delivery between these points. If it is possible to perform this delivery, /order/possible/ returns the estimated price for that delivery.

If your service accepts orders outside of our delivery zones, it's highly likely that many requests to /order/possible/ will return False. Therefore, we recommend calling /order/postcodes/ regularly (once a day for example), caching the results on your server, and locally checking on your server if a given postcode is part of our delivery postcodes. If it's not, you don't have to make a request to /order/possible/ This would speed up your app, since the server wouldn't have to make an extra request to check if an order is possible.

Authentication

Authentication is done by passing your API key in the Authorization header. For example: Authorization: Token 55d7e1d4006b4c3d8baf92df9ee3b02b

Mock order creation

While testing the API, you can pass a boolean parameter {"mock": true}, to avoid creating a real order.

Get Postcodes (GET)

GET /order/postcodes/

Returns a list of 4 digit postcodes (e.g. [1011, 1012, ...]).

Example return values:

200 OK
	  
{
    success: true,
    postcodes: [1011, 1012, ...]
}
	  
	


401 UNAUTHORIZED
	  
{
    success: false,
}
	  
	

Create order (POST)

POST /order/create/

Creates an order. Accepts a JSON with the following parameters:

sender_email (string) -- email address of the sender
sender_phone_number (string) -- phone number of the sender
sender_name (string) -- name of the sender
sender_company_name (string) -- company name of the sender

receiver_email (string) -- email address of the receiver
receiver_phone_number (string) -- phone number of the receiver
receiver_name (string) -- name of the receiver
receiver_company_name (string) -- company name of the receiver

details (string) (max 500 chars) -- details of the delivery

from_postcode (string) -- postcode of the pickup address, is of the form: 1234AB
from_number (int) -- housenumber of the pickup address

to_postcode -- postcode of the delivery address, is of the form: 1234AB
to_number -- housenumber of the delivery address

pickup_time (string) -- pickup time, is of the form: HH:MM (24-hour)
delivery_time (string) -- deliver time, is of the form: HH:MM (24-hour)


Example input:

{
    "sender_email": "earl@example.com",
    "sender_phone": "0612345678",
    "sender_name": "Earl Simmons",
    "sender_company_name": "RR",
    "receiver_email": "daniel@example.com",
    "receiver_phone": "0687654321",
    "receiver_name": "Daniel Dumile",
    "receiver_company_name": "Stones Throw",
    "details": "Please ring the doorbell which says 'DOOM', and deliver to the 3rd floor.",
    "from_postcode": "1012GX",
    "from_number": "23",
    "to_postcode": "1071XX",
    "to_number": "1",
    "pickup_time": "13:00",
    "delivery_time": "14:00",
    "mock": true
} 


Example return values:

200 OK
	  
{
    success: true,
    order_id: 4557119385a740279c502112ab312e83
}
	  
	


401 UNAUTHORIZED
	  
{
    success: false,
}
	  
	


400 BAD REQUEST
	  
{
    errors: ["list_of_errors"]
    success: false,
}
	  
	


400 BAD REQUEST
	  
{
    error_message: "error_message"
    success: false,
}
	  
	

Check if an order is possible (POST)

POST /order/possible/

Given two locations, this function checks if it's possible for our delivery guys to deliver an order between those locations.

Example input:

{
    "from_postcode": "1012GX",
    "from_number": "23",
    "to_postcode": "1071XX",
    "to_number": "1",
} 


Example return values:

200 OK
	  
{
    order_possible: true,
}
	  
	


200 OK
	  
{
    order_possible: false,
    error_message: "error_message"
}
	  
	


401 UNAUTHORIZED
	  
{
    success: false,
}