README
Correios Ex
A Correios API wrapper.
Getting Started
Installation
def deps do
[
{:correios_ex, "~> 0.2"}
]
endAuthentication by Postcard
# Create a client with your credentials
client = CorreiosEx.Client.new(
%{
user: "your_user",
api_code: "your_api_code"
}
)
# Authenticate using a postcard number
{status, response, _} = CorreiosEx.Auth.by_postcard(client, %{"numero" => "0073249300"})
# The response will contain:
# %{"token" => "...", "expiraEm" => "...", "cartaoPostagem" => "..."}Cost Calculation
client = CorreiosEx.Client.new(%{access_token: <token>})
# Calculate shipping cost for a single package (national)
params = %{
cepDestino: "71930000", # Destination ZIP code
cepOrigem: "70902000", # Origin ZIP code
psObjeto: 300 # Weight in grams
}
service_code = "04162" # PAC service code
{status, response, _} = CorreiosEx.Cost.national(client, service_code, params)
# The response will contain:
# %{"pcFinal" => "12,50", ...} # Final price and other cost detailsCorreios API coverage:
that is (almost) the priority order that we should implement this API
- Token
- Prazo v3
- Preço v3
- Meu Contrato
- CEP v3
- Agência v2
- Pré-postagem
- Webhook
- AR Eletrônico
- Faturas
- País v3
- Token - Certificado
- SRO - Interatividade
- SRO - Rastro
- Internacional - Packet
- Mensagem Digital - Ext
Disclaimer: this wrapper was heavily inspired by <a href="https://github.com/edgurgel/tentacat">Tentacat</a>