Overview
An API for generating English sentences for a given input.
How to use Linguatools Sentence Generating API
The API can realise simple sentences given a subject, a verb and an object. Optional additional parameters allow to specify features like tense, number, voice, sentence type. The following table shows example request parameters and their outputs.
request parameters | generated sentence |
subject=police&verb=arrest&object=thief | The police arrests a thief. |
subject=police&verb=arrest&object=thief&tense=past | The police arrested a thief. |
subject=police&verb=arrest&object=thief&tense=past&passive=passive | A thief was arrested by the police. |
subject=police&verb=arrest&object=thief&objmod=suspected&perfect=perfect&objnum=plural&objdet=the | The police has arrested the suspected thieves. |
subject=police&verb=arrest&object=thief&objmod=suspected&perfect=perfect&objnum=plural&objdet=the&sentencetype=yesno | Has the police arrested the suspected thieves? |
Connect to API
Endpoint
You can test the Sentence Generating API and develop your own application – for free – after sign up in RapidAPI
Link to API on RapidApi: https://rapidapi.com/petapro/api/linguatools-sentence-generating
http request & code snippets
RapidAPI provides programming examples for many programming languages like Node.js, Ruby, Java, JavaScript, Python etc. how to use the API.
Query parameters
parameter | description | parameter value |
subject | required | any noun, any pronoun |
subjdet | optional specifies the subject’s determiner. Default is „the“. Use subjdet=- to generate a subject without determiner. | a, the, – |
subjnum | optional specifies the subject’s number. Default is singular. A value of plural is overridden by subjdet=a. | singular, plural |
verb | required | any verb, including phrasal verbs like „start out“ |
object | required If the object is a pronoun set objdet=- and use the base form of the pronoun (e.g. she instead of her). Possible base forms are: I, you, he, she, it, we, they. This will be automatically replaced by me, you, him, her, it, us, them. Set objnum=plural to get the plural forms (e. g. object=he and objdet=- and objnum=plural yields them). | any noun or pronoun |
objdet | optional specifies the object’s determiner. Default is „a“. Use objdet=- to generate an object without determiner. | a, the, – |
objnum | optional specifies the object’s number. Default is singular. A value of plural is overridden by objdet=a. | singular, plural |
objmod | optional specifies an adjective modifying the object | any adjective |
tense | optional specifies the verb’s tense. Default is „present“ | present, past, future |
progressive | optional &progressive=progressive sets the progressive (continuous) tense | progressive |
perfect | optional &perfect=perfect sets the perfect tense | perfect |
negated | optional &negated=negated generates a negated sentence | negated |
passive | optional &passive=passive generates a sentence in passive voice. The object is set as subject and the subject becomes the by-object. | passive |
modal | optional specifies a modal verb modifying the verb. Only allowed for present tense. If tense=past or tense=future is set then the parameter modal will be ignored. | can, may, must, ought, shall, should, would |
sentencetype | optional specifies the sentence type. Default is a declarative sentence. &sentencetype=yesno generates a yes/no-question, whatobj generates a WH-question for the object, whosubj generates a WH-question for the subject | yesno, whatobj, whosubj |
Response
If successful, the response body contains a JSON object with the generated sentence:
1 2 3 | { "result": "OK", "sentence": "The police arrests a thief." } |
If there was an error the response status is 400 and the response body contains a JSON object with an error message:
1 2 3 | { "result": "error", "error_message": "subject is null." } |
Terms of Use
Link: Terms of Use
Pricing
The „BASIC“ plan on RapidAPI with 1.000 requests/month is free.
Demo
The sentence generator https://gramomat.com/ is based on the Sentence Generating API.