Composer
PHP >= 8.2
luannsr12/sdkcorreios
Services offered by the Post Office;
Calculation of shipping for a product;
Tracking an order;
Returns the meanings of the acronyms contained in the tracking code.
Below are the instructions for use:
git clone https://github.com/luannsr12/api-correios/ cd api-correios composer install
After downloading and installing, edit the "config.php" file and add your application's Access Token. This Access Token must be passed in the header of API requests.
All endpoints
Track order
Endpoint: /correios/tracking/
Method: POSTCurls:
curl --location --request GET '{{base_url}}/correios/tracking' --header 'Access-token: SEU_ACCESS_TOKEN' --header 'Content-Type: application/json' --data '{ "objects": ["QQ588651634BR"], "provider": "Muambator" }'Body:
provider is optional. By default, the search site is Best Tracking. See the SDK documentation to see the providers: Sdk Correios
{ "objects": ["QQ588651634BR"], "provider": "Muambator"}Response:
{"success": true,"result": [ {"code": "QQ588651634BR","status": "MOVEMENT","service_provider": "api.melhorrastreio.com.br","data": [ {"date": "03-09-2024 07:27:10","to": "Distribution Unit - MARECHAL CANDIDO RONDON/PR","from": "Treatment Unit - CURITIBA/PR","location ": "Processing Unit - CURITIBA/PR","originalTitle": "Object being transferred - please wait","details": "Object in transfer - please wait"}, {"date": "03-06-2024 12:25:05","to": "Treatment Unit - CASCAVEL/PR","from": "Treatment Unit - SOROCABA/SP","location": "Treatment Unit - SOROCABA/SP","originalTitle": "Object in transfer - please wait","details": "Object in transfer - please wait"} ] } ] }Types of services
Endpoint: /correios/services/
Method: GETCurls:
curl --location '{{base_url}}/correios/services' --header 'Access-token: SEU_ACCESS_TOKEN'Response:
{ "status": "success", "result": {"PAC": "04510","SEDEX": "04014","SEDEX 12": "04782","SEDEX 10": "04790","SEDEX Today": "04804" } }Calculate Shipping
Endpoint: /correios/calculate/
Method: GET
For the type of order, follow the definitions below:
Box/Package (1);
Roller/Prism (2);
Envelope (3);
Important notes:
If it is Envelope, enter 0 at the time;
If it is an Envelope, the weight cannot exceed 1kg;
If it is a Roll/Prism, inform the diameter of the packaging;
If it is Roll/Prisma, enter 0 in height and width;
If Box/Package, enter 0 in diameter;
For "Own Hand" and/or "Receipt Notice" services, enter "Y" - yes or "N" - no;
The Declared value is optional, and if you do not wish to declare it, enter 0;
Curl:
curl --location '{{base_url}}/correios/calculate' --header 'Access-token: SEU_ACCESS_TOKEN' --header 'Content-Type: application/json' --data '{ "servico": "04510", "origem": "85930-000", "destinatario": "85960-000", "tipo": 1, "comprimento": 20, "altura": 20, "largura": 20, "diametro": 0, "peso": 0.500, "maoPropria": "s", "valorDeclarado": 150, "avisoRecebimento": "s" }'Body:
{ "service": "04510", "source": "12460-000", "recipient": "37530-000", "type": 1, "length": 20, "height": 20, "width" : 20, "diameter": 0, "weight": 0.500, "handOwn": "s", "declaredvalue": 150, "receipt notice": "s"}Response:
^ 29.40", "ValorMaoPropria": "7.50", "ValorAvisoRecebimento": "6.35", "ValorValorDeclarado": "2.58", "Domiciliar Delivery": "Y", "SaturdayDelivery": "N", "obsFim": [], "Error": "0", "MsgError": [] } } }Get the acronym by ID
Endpoint: /correios/flag/
Method: GETCurls:
curl --location --request GET '{{base_url}}/correios/flag' --header 'Access-token: SEU_ACCESS_TOKEN' --header 'Content-Type: application/json' --data '{ "Id": "AR" }'Body:
{"Id": "AR"}Response:
{"success": true,"result": {"Id": "AR","Name": "ACKNOWLEDGMENT OF RECEIPT"} }List all acronyms
Endpoint: /correios/flags/
Method: GETCurls:
curl --location '{{base_url}}/correios/flags' --header 'Access-token: SEU_ACCESS_TOKEN'Response:
{"success": true,"result": {"AL": {"name": "READING AGENTS"},"AR": {"name": "ACKNOWLEDGMENT OF RECEIPT"},"AS": {" name": "PAC ORDER – SOCIAL ACTION"},"BE": {"name": "ECONOMIC REMITTANCE WITHOUT DIGITAL AIR"},"BF": {"name": "EXPRESS SHIPPING WITHOUT DIGITAL AIR"} } }Contributors
@luannsr12
@germano-rs
@pauloalmeidasilva