--- title: What is Total API project: Total API version: 2026 section: guides language: en license: url: https://totaljs.es/docs/total-api/2026/guides/introduction/ updated: 2026-11-19T06:09:14.885Z --- # What is Total API > Ready-made web services of the Total.js Platform that any application can call with a token. Total API is a set of ready-made web services of the Total.js Platform. Your application sends a request with your token, and Total API does the work: it prints a PDF, reads text from an image, sends an email, checks a VAT number and more. You pay a small price for each request from the credits of your token. Total.js applications call it with one line of code. Any other application calls it over HTTP. ## Services | Service | What it does | | --- | --- | | [Printer](../../reference/documents-and-images/#print) | Prints HTML or a web page to PDF, JPG or PNG | | [Convertor](../../reference/documents-and-images/#convert) | Converts a file to PDF, JPG or PNG | | [OCR](../../reference/documents-and-images/#ocr) | Reads the text of an image or a PDF | | [Invoice parser](../../reference/documents-and-images/#invoiceparser) | Reads the data of an invoice from a PDF, JPG or PNG | | [Plate number parser](../../reference/documents-and-images/#platenumber) | Reads a license plate from a picture | | [Captcha image generator](../../reference/documents-and-images/#captcha) | Draws a captcha image | | [Email](../../reference/messages/#mail) | Sends an email | | [Send SMS](../../reference/messages/#sms) | Sends a text message | | [Logger](../../reference/messages/#logger) | Stores a log message in the Total.js Platform | | [IP geolocation](../../reference/data/#geoip) | Finds the place of an IP address | | [Exchange rates](../../reference/data/#exchangerates) | Reads the exchange rates of a day | | [Check company VAT ID](../../reference/data/#checkvat) | Checks a VAT number in the European Union | | [Current weather](../../reference/data/#weather) | Reads the weather of a place | | [Chat GPT](../../reference/ai/#chatgpt) | Asks ChatGPT a question | | [Check credits](../../reference/account/#check) | Returns the credits of your token, for free | ## Read next 1. [Get a token](../get-a-token/) 2. [Call Total API from Total.js](../call-from-totaljs/) or [call it over HTTP](../call-over-http/) --- title: Get a token project: Total API version: 2026 section: guides language: en license: url: https://totaljs.es/docs/total-api/2026/guides/get-a-token/ updated: 2026-11-19T06:09:14.885Z --- # Get a token > Get the token that every request to Total API needs, and check its credits. Every request to Total API needs your token. The token identifies you, and each request takes its price from the credits of the token. ## Get it 1. Open the [Total.js Platform](https://platform.totaljs.com?open=api) and sign in with your Total.js account. 2. Open the **API** section. It shows your token, your credits and the current price of each service. 3. Copy the token. Keep the token secret, like a password: anyone who has it can spend its credits. Put it in the configuration of your application, never in code that a browser downloads. ## Check the credits The [check](../../reference/account/#check) service returns the credits that remain. It is free. ```js var response = await API('TAPI', 'check').promise(); console.log(response.credits); ``` --- title: Call Total API from Total.js project: Total API version: 2026 section: guides language: en license: url: https://totaljs.es/docs/total-api/2026/guides/call-from-totaljs/ updated: 2026-11-19T06:09:14.885Z --- # Call Total API from Total.js > Configure the token and call any service with API('TAPI') or TotalAPI() in a Total.js application. Total.js applications have a built-in client for Total API. You only add your token to the configuration. ## Configure the token Add the `totalapi` key to the `config` file of your application: ```text totalapi : YOUR_TOKEN ``` ## Call a service `API('TAPI', service, data)` calls a service. The first argument is always `TAPI`, the second one is the name of the service and the third one its data. With `await`: ```js var response = await API('TAPI', 'weather', 'Bratislava').promise(); ``` With a callback: ```js API('TAPI', 'weather', 'Bratislava').callback(function(err, response) { if (err) console.log('Error:', err); else console.log(response.temperature); }); ``` `TotalAPI(service, data, callback)` does the same in a shorter form: ```js TotalAPI('weather', 'Bratislava', function(err, response) { console.log(err, response); }); ``` ## Data as text When the data is text, a number or a boolean instead of an object, the client sends it as `{ value: ... }`. These two calls are the same: ```js API('TAPI', 'weather', 'Bratislava'); API('TAPI', 'weather', { value: 'Bratislava' }); ``` ## Errors When Total API refuses a request, the error is its message, for example `Invalid token` when the token is missing or wrong. ## Send the emails of the app through Total API With `$tapimail` set to `true`, the emails that the application sends with `MAIL()` go through the [mail](../../reference/messages/#mail) service instead of an SMTP server: ```text totalapi : YOUR_TOKEN $tapimail : true ``` ## Send the audit logs to Total API With `$tapilogger` set to `true`, the audit logs of the application (`AUDIT()`) go to the [logger](../../reference/messages/#logger) service: ```text totalapi : YOUR_TOKEN $tapilogger : true ``` --- title: Call Total API over HTTP project: Total API version: 2026 section: guides language: en license: url: https://totaljs.es/docs/total-api/2026/guides/call-over-http/ updated: 2026-11-19T06:09:14.885Z --- # Call Total API over HTTP > Call any service from any language with a POST request, your token and a JSON body. Every service is a `POST` request to its own address. Any language or tool that sends HTTP requests can use Total API. ## The request | Part | Value | | --- | --- | | Method | `POST` | | Address | `https://api.totaljs.com/{service}/`, for example `https://api.totaljs.com/weather/` | | Header `Content-Type` | `application/json` | | Header `X-Token` | Your token | | Body | The data of the service as JSON | ```bash curl -X POST https://api.totaljs.com/weather/ \ -H "Content-Type: application/json" \ -H "X-Token: YOUR_TOKEN" \ -d '{ "value": "Bratislava" }' ``` ## The answer - **Success:** status `200` and the result: JSON, or the file itself for the services that create files ([print](../../reference/documents-and-images/#print) and [convert](../../reference/documents-and-images/#convert)). - **Error:** status `400` and a JSON array with the message: ```json [{ "error": "Invalid token" }] ``` --- title: Documents and images project: Total API version: 2026 section: reference language: en license: url: https://totaljs.es/docs/total-api/2026/reference/documents-and-images/ updated: 2026-11-20T06:51:47.968Z --- # Documents and images > Print, convert and read files: PDF, OCR, invoices, license plates and captcha images. Every service is a `POST` request with your token. See [Call Total API from Total.js](../../guides/call-from-totaljs/) and [Call Total API over HTTP](../../guides/call-over-http/). ## API ### POST https://api.totaljs.com/print/ Type: `rest` Prints HTML or a web page to PDF, JPG or PNG. | Parameter | Type | Required | Default | Description | | --- | --- | --- | --- | --- | | `type` | `String` | yes | | `pdf`, `jpg` or `png`. | | `html` | `String` | no | | The HTML to print. Send `html` or `url`. | | `url` | `String` | no | | The address of a web page to print. | | `page` | `String` | no | `A4` | `A3`, `A4`, `A5` or `Letter`. | | `width` | `Number` | no | | PDF: the width of the page. Image: the width of the browser, in pixels. | | `height` | `Number` | no | | PDF: the height of the page. Image: the height of the browser, in pixels. | | `dpi` | `Number` | no | `96` | PDF only. | | `margin` | `String` | no | `0 0 0 0` | PDF only: `top right bottom left` in millimeters. | | `viewport` | `String` | no | | `xs` (phone), `sm` (tablet), `md` (medium screen) or `lg` (large screen). | | `quality` | `Number` | no | | The quality of an image. | | `orientation` | `String` | no | `portrait` | `portrait` or `landscape`. | | `grayscale` | `Boolean` | no | | PDF only: a grayscale document. | | `lowquality` | `Boolean` | no | | PDF only: a smaller document of lower quality. | | `zoom` | `Number` | no | `100` | The zoom in percent. | Returns: `Binary` The file itself (binary data). The HTML or the web page can have up to 512 kB. Example: Total.js ```js var file = await API('TAPI', 'print', { type: 'pdf', html: '
Thank you for your order.
' }).promise(); ``` Example: REST ```bash curl -X POST https://api.totaljs.com/mail/ \ -H "Content-Type: application/json" \ -H "X-Token: YOUR_TOKEN" \ -d '{ "from": "Demo Shop", "to": ["jane@example.com"], "subject": "Your order", "body": "Thank you for your order.
" }' ``` Example: Response ```json { "success": true } ``` ### POST https://api.totaljs.com/sms/ Type: `rest` Sends a text message. | Parameter | Type | Required | Default | Description | | --- | --- | --- | --- | --- | | `from` | `String` | yes | | The name of the sender. | | `to` | `String` | yes | | The phone number with its country code, for example `+421900000000`. | | `body` | `String` | yes | | The message. | Returns: `Object` `{ "success": true }` when the message is sent. The price of a message can vary. Example: Total.js ```js await API('TAPI', 'sms', { from: 'Demo Shop', to: '+421900000000', body: 'Your order is on its way.' }).promise(); ``` Example: REST ```bash curl -X POST https://api.totaljs.com/sms/ \ -H "Content-Type: application/json" \ -H "X-Token: YOUR_TOKEN" \ -d '{ "from": "Demo Shop", "to": "+421900000000", "body": "Your order is on its way." }' ``` Example: Response ```json { "success": true } ``` ### POST https://api.totaljs.com/logger/ Type: `rest` Stores a log message in the Total.js Platform. | Parameter | Type | Required | Default | Description | | --- | --- | --- | --- | --- | | `app` | `String` | yes | | The name of the application, up to 40 characters. | | `message` | `String` | yes | | The message, up to 500 characters. | | `type` | `String` | no | `info` | `info`, `warning`, `error` or `success`. | | `url` | `String` | no | | An address, up to 100 characters. | | `reference` | `String` | no | | A reference of your own, up to 50 characters. | | `data` | `String` | no | | Data of your own as JSON text. | | `ua` | `String` | no | | The user agent, up to 30 characters. | | `ip` | `String` | no | | The IP address, up to 60 characters. | | `userid` | `String` | no | | The id of the user, up to 25 characters. | | `username` | `String` | no | | The name of the user, up to 50 characters. | Returns: `Object` The answer of the service. A request can have up to 50 kB. A Total.js application can send all its audit logs to this service: see [Call Total API from Total.js](../../guides/call-from-totaljs/#send-the-audit-logs-to-total-api). Example: Total.js ```js await API('TAPI', 'logger', { app: 'Demo Shop', type: 'info', message: 'The daily import has finished.' }).promise(); ``` Example: REST ```bash curl -X POST https://api.totaljs.com/logger/ \ -H "Content-Type: application/json" \ -H "X-Token: YOUR_TOKEN" \ -d '{ "app": "Demo Shop", "type": "info", "message": "The daily import has finished." }' ``` --- title: Data project: Total API version: 2026 section: reference language: en license: url: https://totaljs.es/docs/total-api/2026/reference/data/ updated: 2026-11-20T06:51:47.968Z --- # Data > Look up places of IP addresses, exchange rates, VAT numbers and the weather. Every service is a `POST` request with your token. See [Call Total API from Total.js](../../guides/call-from-totaljs/) and [Call Total API over HTTP](../../guides/call-over-http/). ## API ### POST https://api.totaljs.com/geoip/ Type: `rest` Finds the place of an IP address. | Parameter | Type | Required | Default | Description | | --- | --- | --- | --- | --- | | `value` | `String` | yes | | The IP address. | Returns: `Object` The country, region, city, coordinates, provider and time zone of the address. Example: Total.js ```js var place = await API('TAPI', 'geoip', '78.98.116.204').promise(); ``` Example: REST ```bash curl -X POST https://api.totaljs.com/geoip/ \ -H "Content-Type: application/json" \ -H "X-Token: YOUR_TOKEN" \ -d '{ "value": "78.98.116.204" }' ``` Example: Response ```json { "ip": "78.98.116.204", "isp": "Slovak Telekom, a.s.", "country": "Slovakia", "country_code": "SK", "region": "Banska Bystrica", "region_code": "BC", "city": "Banská Bystrica", "zip": "974 01", "continent": "Europe", "continent_code": "EU", "lat": 48.804, "lng": 19.1363, "timezone": "Europe/Bratislava" } ``` ### POST https://api.totaljs.com/exchangerates/ Type: `rest` Reads the exchange rates of a currency on a day. | Parameter | Type | Required | Default | Description | | --- | --- | --- | --- | --- | | `currency` | `String` | no | `EUR` | The base currency. | | `date` | `String` | no | `today` | The day, for example `2026-11-19`. | Returns: `Object` An object with one rate for each currency. The answer has more currencies than this example shows. Example: Total.js ```js var rates = await API('TAPI', 'exchangerates', { currency: 'EUR', date: '2026-11-19' }).promise(); console.log(rates.USD); ``` Example: REST ```bash curl -X POST https://api.totaljs.com/exchangerates/ \ -H "Content-Type: application/json" \ -H "X-Token: YOUR_TOKEN" \ -d '{ "currency": "EUR", "date": "2026-11-19" }' ``` Example: Response ```json { "USD": 1.2109, "GBP": 0.9, "CHF": 1.0764, "CZK": 26.239, "PLN": 4.4246, "JPY": 126.05 } ``` ### POST https://api.totaljs.com/checkvat/ Type: `rest` Checks whether a company is a VAT payer in the European Union. | Parameter | Type | Required | Default | Description | | --- | --- | --- | --- | --- | | `value` | `String` | yes | | The VAT ID, for example `SK2120417167`. | Returns: `Object` Whether the company pays VAT, the VAT rate of its country, its name and its address. It works only with VAT IDs of the European Union. `is` says whether the company is a VAT payer, and `vat` is the VAT rate of its country. Example: Total.js ```js var company = await API('TAPI', 'checkvat', 'SK2120417167').promise(); ``` Example: REST ```bash curl -X POST https://api.totaljs.com/checkvat/ \ -H "Content-Type: application/json" \ -H "X-Token: YOUR_TOKEN" \ -d '{ "value": "SK2120417167" }' ``` Example: Response ```json { "is": true, "vat": 20, "name": "Total Avengers s. r. o.", "address": "Viestova 6784/28\n97401 Banská Bystrica\nSlovensko" } ``` ### POST https://api.totaljs.com/weather/ Type: `rest` Reads the current weather of a place. | Parameter | Type | Required | Default | Description | | --- | --- | --- | --- | --- | | `value` | `String` | yes | | The place, for example `Bratislava`. | Returns: `Object` The temperature, wind, humidity, pressure, clouds, UV index and sky. Example: Total.js ```js var weather = await API('TAPI', 'weather', 'Bratislava').promise(); ``` Example: REST ```bash curl -X POST https://api.totaljs.com/weather/ \ -H "Content-Type: application/json" \ -H "X-Token: YOUR_TOKEN" \ -d '{ "value": "Bratislava" }' ``` Example: Response ```json { "name": "Bratislava", "temperature": 22, "wind": 20.2, "humidity": 65, "pressure": 1018, "cloud": 25, "uv": 6, "sky": "Partly cloudy" } ``` --- title: AI project: Total API version: 2026 section: reference language: en license: url: https://totaljs.es/docs/total-api/2026/reference/ai/ updated: 2026-11-20T06:51:47.968Z --- # AI > Ask ChatGPT. Every service is a `POST` request with your token. See [Call Total API from Total.js](../../guides/call-from-totaljs/) and [Call Total API over HTTP](../../guides/call-over-http/). ## API ### POST https://api.totaljs.com/chatgpt/ Type: `rest` Asks ChatGPT a question. | Parameter | Type | Required | Default | Description | | --- | --- | --- | --- | --- | | `value` | `String` | yes | | The question. | | `output` | `String` | no | `text` | `text` or `image`. | | `size` | `String` | no | | The size of an image: `small`, `medium` or `large`. Only with `output: image`. | Returns: `Object` An object with the answer in `text`. Example: Total.js ```js var answer = await API('TAPI', 'chatgpt', 'What is Total.js Platform?').promise(); console.log(answer.text); ``` Example: REST ```bash curl -X POST https://api.totaljs.com/chatgpt/ \ -H "Content-Type: application/json" \ -H "X-Token: YOUR_TOKEN" \ -d '{ "value": "What is Total.js Platform?" }' ``` Example: Response ```json { "text": "Total.js Platform is a web development platform for Node.js..." } ``` --- title: Account project: Total API version: 2026 section: reference language: en license: url: https://totaljs.es/docs/total-api/2026/reference/account/ updated: 2026-11-20T06:51:47.968Z --- # Account > Check the credits of your token. Every service is a `POST` request with your token. See [Call Total API from Total.js](../../guides/call-from-totaljs/) and [Call Total API over HTTP](../../guides/call-over-http/). ## API ### POST https://api.totaljs.com/check/ Type: `rest` Returns the credits that remain on your token. Returns: `Object` An object with the credits in `credits`. It is free. Example: Total.js ```js var response = await API('TAPI', 'check').promise(); console.log(response.credits); ``` Example: REST ```bash curl -X POST https://api.totaljs.com/check/ \ -H "Content-Type: application/json" \ -H "X-Token: YOUR_TOKEN" ``` Example: Response ```json { "credits": 34.49 } ``` --- title: Questions about Total API project: Total API version: 2026 section: faq language: en license: url: https://totaljs.es/docs/total-api/2026/faq/questions/ updated: 2026-11-19T06:09:14.885Z --- # Questions about Total API > Short answers about the price, the token, errors and the address of the services. ## How much does a request cost? Each service has its own price per request. The **API** section of the [Total.js Platform](https://platform.totaljs.com?open=api) shows the current prices and your credits. [check](../../reference/account/#check) is free. ## Why does every request fail with `Invalid token`? The token is missing or wrong. In a Total.js application, check the `totalapi` key of the `config` file. Over HTTP, check the `X-Token` header. See [Get a token](../../guides/get-a-token/). ## Can I use Total API without Total.js? Yes. Every service is a `POST` request with JSON. See [Call Total API over HTTP](../../guides/call-over-http/). ## Which address does a Total.js application use? A Total.js 5 application calls `https://eu.api.totaljs.com/{service}/`. Requests from other applications go to `https://api.totaljs.com/{service}/`. Both answer in the same way.