This API allows you to easily integrate with other applications. In the examples below we use
cURL, but you can adapt them to any programming language.
All examples work with JSON, too - just change XML to JSON.
NOTE: The current documentation is available on GitHub: https://github.com/InvoiceOcean/api
You can get your API token by going to Settings -> Account settings -> Integration -> API Authorization Code in your InvoiceOcean account.
select invoice from current month:
XML curl "http://YOUR_DOMAIN.invoiceocean.com/invoices.xml?period=this_month&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
JSON curl "http://YOUR_DOMAIN.invoiceocean.com/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)
XML curl "http://YOUR_DOMAIN.invoiceocean.com/invoices/100.xml&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
JSON curl "http://YOUR_DOMAIN.invoiceocean.com/invoices/100.json&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
XML curl "http://YOUR_DOMAIN.invoiceocean.com/invoices?oid=nr_zam&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
JSON curl "http://YOUR_DOMAIN.invoiceocean.com/invoices?oid=nr_zam&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
JSON (recommended) >
curl http://YOUR_DOMAIN.invoiceocean.com/invoices.json -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", "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} ] }}'
Get Code CURL
endpoint = 'http://YOUR_DOMAIN.invoiceocean.com/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 code
If you have a certain client (client_id) and a seller (department_id):
curl http://YOUR_DOMAIN.invoiceocean.com/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 CURL
XML curl http://YOUR_DOMAIN.invoiceocean.com/invoices.xml -u 'login:YOUR_PASSWORD -H 'Accept: application/xml' -H 'Content-Type: application/xml' -d '
Get Code CURL
XML curl -X DELETE "http://YOUR_DOMAIN.invoiceocean.com/invoices/100.xml?api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
JSON curl -X DELETE "http://YOUR_DOMAIN.invoiceocean.com/invoices/100.json?api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
curl "http://YOUR_DOMAIN.invoiceocean.com/products.xml&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
curl "http://YOUR_DOMAIN.invoiceocean.com/products/100.xml&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
To download the payments form (in the form of JS), call the URL:
http://app.invoiceocean.dev/a/YOUR_DOMAIN/p/{{token}}.js
where {{token}} is the token of the product
curl "http://YOUR_DOMAIN.invoiceocean.com/clients.xml&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
curl "http://YOUR_DOMAIN.invoiceocean.com/clients/100.xml&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
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.invoiceocean.com/clients/check?email=marcin@email.com&password=haslo_przykladowe&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
note: it is important for the url to have apostrophes
XML curl "http://YOUR_DOMAIN.invoiceocean.com/payments.xml&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
JSON curl "http://YOUR_DOMAIN.invoiceocean.com/payments.json&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
XML curl "http://YOUR_DOMAIN.invoiceocean.com/payments/100.xml&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
JSON curl "http://YOUR_DOMAIN.invoiceocean.com/payment/100.json&api_token=YOUR_TOKEN_FROM_APP_SETTINGS"
JSON (recomended) curl http://YOUR_DOMAIN.invoiceocean.com/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 CURL
More examples: https://github.com/invoiceocean/api