0.1.0 • Published 6 years ago
gaia-api-js v0.1.0
GAIA API - JavaScript
This repository hosts an API for accessing GAIA remote services.
Installing
Use npm install gaia-api-js or yarn add gaia-api-js.
Usign GAIA API
Before using this API, you have to initialize the service with the API key provided.
const GAIA = require('gaia-api-js')
const service = new GAIA('550e8400-e29b-41d4-a716-446655440000')All the returning values are dependant of the OpenAPI specification for GAIA. Please, check it out here first.
Classification
You can classify any content using GAIA.classification. Here is an example.
const result = await service.classification(
'es', // Language code matching the standard ISO 639.
'Real Madrid, en la cuerda floja', // Title of the content.
'¡Cristiano la lía parda!', // Introduction of the content.
'Dos golpes tan seguidos...', // Text of the content.
'https://marca.com' // Source of the content.
)Returning result will be an object with two parameters:
codeis astringwith the result code (example:200)datais anobjectwith the result data. Please check the OpenAPI specification of this data (ClassificationResponseBody) here.
Filtering
You can classify any content using GAIA.filtering. Here is an example.
const result = await service.filtering(
'es', // Language code matching the standard ISO 639.
'Real Madrid, en la cuerda floja. Dos golpes tan seguidos...' // Text of the content.
)Returning result will be an object with two parameters:
codeis astringwith the result code (example:200)datais anobjectwith the result data. Please check the OpenAPI specification of this data (FilteringResponseBody) here.
Error handling
Service will fire an error when an unexpected behaviour occurs. This error has the next structure:
codeis astringwith the error code (example:500)nameis astringto display the error name.messageis astringto display the error message.stackis the error stack.
Dependencies
axiosis used for asynchronous request.