Api
This API allows you to easily integrate with other applications. In the examples below we use
CURL tool - you can easily change it to any computer language.
Please contact us If you want any additional API function, we will add it as fast as possible.
All examples work with JSON too (you simply need to change xml extension to json)
NOTE: The current documentation is available on GitHub: https://github.com/InvoiceOcean/api
# All this code is just for demonstration purposes
React.api_key = "In here goes your api key!"
API token
API token you have to download the application settings ("Settings -> Account Settings -> Integration -> API Authorization Code")
Invoices
Select all invoices from a selected time period
select invoice from current month:
XML
curl "http://YOUR_DOMAIN.fakturownia.pl/invoices.xml?period=this_month&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
JSON curl "http://YOUR_DOMAIN.fakturownia.pl/invoices.json?period=this_month&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
You can pass the same parameters that are passed to the application (on the list of invoices)Select invoice by ID
XML
curl "http://YOUR_DOMAIN.fakturownia.pl/invoices/100.xml&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
JSON curl "http://YOUR_DOMAIN.fakturownia.pl/invoices/100.json&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
Downloading your invoice for Order ID
XML
curl "http://YOUR_DOMAIN.fakturownia.pl/invoices?oid=nr_zam&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
JSON curl "http://YOUR_DOMAIN.fakturownia.pl/invoices?oid=nr_zam&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
Add new invoice
JSON (recommended) >
CURL
curl https://YOUR_DOMAIN.fakturownia.pl/invoices.json
-H 'Accept: application/json'
-H 'Content-Type: application/json'
-d '{
"api_token": "API_TOKEN",
"invoice": {
"kind":"vat",
"number": null,
"sell_date": "2015-02-10",
"issue_date": "2015-02-10",
"payment_to": "2015-02-17",
"seller_name": "Seller Sp. z o.o.",
"seller_tax_no": "5252445767",
"buyer_name": "Client1 Sp. z o.o.",
"buyer_tax_no": "5252445767",
"positions":[
{"name":"Produkt A1", "tax":23, "total_price_gross":10.23, "quantity":1},
{"name":"Produkt A2", "tax":0, "total_price_gross":50, "quantity":2}
]
}}'
Ruby
endpoint = 'http://YOUR_DOMAIN.fakturownia.pl/invoices.json' uri = URI.parse(endpoint) json_params = { "api_token" => "YOUR_TOKEN_FROM_APP_SETTINGS", "invoice" => { "kind" =>"vat", "number" => nil, "sell_date" => "2013-02-07", "issue_date" => "2013-02-07", "payment_to" => "2013-02-14", "seller_name" => "Wystawca Sp. z o.o.", "seller_tax_no" => "5252445767", "buyer_name" => "Klient1 Sp. z o.o.", "buyer_tax_no" => "5252445767", "positions" =>[ {"name" =>"Produkt A1", "tax" =>23, "total_price_gross" =>10.23, "quantity" =>1}, {"name" =>"Produkt A2", "tax" =>0, "total_price_gross" =>50, "quantity" =>3} ] }} request = Net::HTTP::Post.new(uri.path) request.body = JSON.generate(json_params) request["Content-Type"] = "application/json" http = Net::HTTP.new(uri.host, uri.port) response = http.start {|h| h.request(request)} if response.code == '201' ret = JSON.parse(response.body) else ret = response.body end puts ret.to_json
Download Ruby codeJeśli masz danego klienta (client_id) i sprzedawcę (department_id):
curl http://YOUR_DOMAIN.fakturownia.pl/invoices.json -u 'login:YOUR_PASSWORD -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"api_token": "YOUR_TOKEN_FROM_APP_SETTINGS", "invoice": { "kind":"vat", "number": null, "sell_date": "2013-02-07", "issue_date": "2013-02-07", "payment_to": "2013-02-14", "department_id": 1, "client_id": 2, "buyer_name": "Klient1 Sp. z o.o.", "buyer_tax_no": "5252445767", "positions":[ {"name":"Produkt A1", "tax":23, "total_price_gross":10.23, "quantity":1}, {"name":"Produkt A2", "tax":0, "total_price_gross":50, "quantity":3} ] }}'
Get Code CURLXML
curl http://YOUR_DOMAIN.fakturownia.pl/invoices.xml -u 'login:YOUR_PASSWORD -H 'Accept: application/xml' -H 'Content-Type: application/xml' -d ' vat 2013-02-07 2013-02-07 2013-02-14 Wystawca Sp. z o.o. 5252445767 Klient1 Sp. z o.o. 5252445767 Produkt X1 23 20 1 Produkt X2 0 10 3 '
Get Code CURL
Usunięcie faktury
XML
curl -X DELETE "http://YOUR_DOMAIN.fakturownia.pl/invoices/100.xml?api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
JSON curl -X DELETE "http://YOUR_DOMAIN.fakturownia.pl/invoices/100.json?api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
Products / services
Products
curl "http://YOUR_DOMAIN.fakturownia.pl/products.xml&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
Select product using their ID
curl "http://YOUR_DOMAIN.fakturownia.pl/products/100.xml&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
Widget
Aby pobrać formatkę płatności (w postaci JS) należy wywołać URL:
http://app.fakturownia.dev/a/YOUR_DOMAIN/p/{{token}}.js
gdzie {{token}} to wartość pola token z danego produktu
Clients
Clients
curl "http://YOUR_DOMAIN.fakturownia.pl/clients.xml&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
Select client using their ID
curl "http://YOUR_DOMAIN.fakturownia.pl/clients/100.xml&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
Get client by e-mail or password
it is useful to you have an active control panel of your clients, so they can login by e-mail and password.
curl "http://YOUR_DOMAIN.fakturownia.pl/clients/check?email=marcin@email.com&password=haslo_przykladowe&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
uwaga: ważne objęcie url-a w apostrofyPayments
Payments
XML
curl "http://YOUR_DOMAIN.fakturownia.pl/payments.xml&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
JSON curl "http://YOUR_DOMAIN.fakturownia.pl/payments.json&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
Select payment using their ID
XML
curl "http://YOUR_DOMAIN.fakturownia.pl/payments/100.xml&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
JSON curl "http://YOUR_DOMAIN.fakturownia.pl/payment/100.json&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
Dodawanie nowej płatności
JSON (recomended)
curl http://YOUR_DOMAIN.fakturownia.pl/payments.json -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{ "api_token": "YOUR_TOKEN_FROM_APP_SETTINGS", "payment": { "city": null, "client_id":null, "comment":null, "country":null, "currency":"PLN", "deleted":false, "department_id":null, "description":"abonament roczny", "email":"email@email.pl", "first_name":"Jan", "generate_invoice":true, "invoice_city":"Warszawa", "invoice_comment":"", "invoice_country":null, "invoice_id":null, "invoice_name":"Company name", "invoice_post_code":"00-112", "invoice_street":"street 52", "invoice_tax_no":"5252445767", "last_name":"Kowalski", "name":"Plantnosc za produkt1", "oid":"", "paid":true, "paid_date":null, "phone":null, "post_code":null, "price":"100.00", "product_id":1, "promocode":"", "provider":"transfer", "provider_response":null, "provider_status":null, "provider_title":null, "quantity":1, "street":null }}'
Get Code CURLMore examples: https://github.com/radgost/fakturownia-api