Instead of ‘login’ and ‘password’ use your credentials from https://app.dataforseo.com/api-access
<?php // You can download this file from here https://cdn.dataforseo.com/v3/examples/php/php_RestClient.zip require('RestClient.php'); $api_url = 'https://api.dataforseo.com/'; try { // Instead of 'login' and 'password' use your credentials from https://app.dataforseo.com/api-access $client = new RestClient($api_url, null, 'login', 'password'); } catch (RestClientException $e) { echo "n"; print "HTTP code: {$e->getHttpCode()}n"; print "Error code: {$e->getCode()}n"; print "Message: {$e->getMessage()}n"; print $e->getTraceAsString(); echo "n"; exit(); } try { // using this method you can get a list of grammar rules // GET /v3/content_generation/grammar_rules // the full list of possible parameters is available in the documentation $result = $client->get('/v3/content_generation/grammar_rules'); print_r($result); // do something with result } catch (RestClientException $e) { echo "n"; print "HTTP code: {$e->getHttpCode()}n"; print "Error code: {$e->getCode()}n"; print "Message: {$e->getMessage()}n"; print $e->getTraceAsString(); echo "n"; } $client = null; ?>
The above command returns JSON structured like this:
{ "version": "0.1.20221214", "status_code": 20000, "status_message": "Ok.", "time": "0.0538 sec.", "cost": 0, "tasks_count": 1, "tasks_error": 0, "tasks": [ { "id": "12221847-1535-0513-0000-c0fa348e825f", "status_code": 20000, "status_message": "Ok.", "time": "0.0000 sec.", "cost": 0, "result_count": 1, "path": [ "v3", "content_generation", "grammar_rules" ], "data": { "api": "content_generation", "function": "grammar_rules" }, "result": [ { "rules": [ "ALLT_MER", "ARABIC_COMMA_PARENTHESIS_WHITESPACE", "ARABIC_DOUBLE_PUNCTUATION", "ARABIC_WORD_REPEAT_RULE", "AR_DIACRITICS_REPLACE", "AR_SIMPLE_REPLACE", "BERT_SUGGESTION_RANKING", "BR_TOPO", "CATALAN_WORD_REPEAT_RULE", "CA_UNPAIRED_BRACKETS", "CA_UNPAIRED_EXCLAMATION", "CA_UNPAIRED_QUESTION", "COMMA_PARENTHESIS_WHITESPACE", "CONFUSION_RULE", "DAAN", "DASH", "DASH_RULE", "DEMO_RULE", "DE_DOUBLE_PUNCTUATION", "DE_SENTENCE_WHITESPACE", "DE_SIMPLE_REPLACE", "DIFFERENT_PUNCTUATION", "DOUBLE_PUNCTUATION", "DOUSI_DEHA", "DOYATTE", "DUTCH_WRONG_WORD_IN_CONTEXT", "D_WORDS", "EK_DE", "EL_UNPAIRED_BRACKETS", "EMPTY_LINE", "ENGLISH_WORD_REPEAT_BEGINNING_RULE", "ENGLISH_WORD_REPEAT_RULE", "ENGLISH_WRONG_WORD_IN_CONTEXT", "EN_A_VS_AN", "EN_COMPOUNDS", "EN_CONTRACTION_SPELLING", "EN_DASH_RULE", "EN_DIACRITICS_REPLACE", "EN_FOR_DE_SPEAKERS_FALSE_FRIENDS", "EN_FOR_ES_SPEAKERS_FALSE_FRIENDS", "EN_FOR_FR_SPEAKERS_FALSE_FRIENDS", "EN_FOR_NL_SPEAKERS_FALSE_FRIENDS", "EN_GB_SIMPLE_REPLACE", "EN_NZ_SIMPLE_REPLACE", "EN_PLAIN_ENGLISH_REPLACE", "EN_REDUNDANCY_REPLACE", "EN_SIMPLE_REPLACE", "EN_SPECIFIC_CASE", "EN_UNPAIRED_BRACKETS", "EN_UPPER_CASE_NGRAM", "EN_US_SIMPLE_REPLACE", "EN_WORD_COHERENCY", "ES_QUESTION_MARK", "ES_UNPAIRED_BRACKETS", "ES_WIKIPEDIA_COMMON_ERRORS", "FAKE_FOR_VAGUE_SPELL_CHECKER", "FA_SIMPLE_REPLACE", "FA_SPACE_BEFORE_CONJUNCTION", "FILLER_WORDS", "FR_COMPOUNDS", "FR_SPELLING_RULE", "GERMAN_WORD_REPEAT_RULE", "GREEK_ORTHOGRAPHY_NUMERAL_STRESS", "GR_01_001", "HUNSPELL_NO_SUGGEST_RULE", "HUNSPELL_RULE", "HUNSPELL_RULE_AR", "ITALIAN_WORD_REPEAT_RULE", "KAIKETUNARU", "KEMM_DRE_C_HWEZHADENNIN_AR", "KEMM_DRE_VLOTAAT_AR", "MEISI_DESUMU", "METRIC_UNITS_EN_GENERAL", "METRIC_UNITS_EN_IMPERIAL", "METRIC_UNITS_EN_US", "MISSING_VERB", "MORFOLOGIK_RULE_BR_FR", "MORFOLOGIK_RULE_CA_ES", "MORFOLOGIK_RULE_EL_GR", "MORFOLOGIK_RULE_EN_AU", "MORFOLOGIK_RULE_EN_CA", "MORFOLOGIK_RULE_EN_GB", "MORFOLOGIK_RULE_EN_NZ", "MORFOLOGIK_RULE_EN_US", "MORFOLOGIK_RULE_EN_ZA", "MORFOLOGIK_RULE_ES", "MORFOLOGIK_RULE_IT_IT", "MORFOLOGIK_RULE_NL_NL", "MORFOLOGIK_RULE_PL_PL", "MORFOLOGIK_RULE_RO_RO", "MORFOLOGIK_RULE_RU_RU", "MORFOLOGIK_RULE_SL_SI", "MORFOLOGIK_RULE_TL", "MORFOLOGIK_RULE_UK_UA", "MOTISITE", "NL_COMPOUNDS", "NL_SIMPLE_REPLACE", "NL_WORD_COHERENCY", "OLD_SPELLING", "PARAGRAPH_REPEAT_BEGINNING_RULE", "PERSIAN_COMMA_PARENTHESIS_WHITESPACE", "PERSIAN_DOUBLE_PUNCTUATION", "PERSIAN_WORD_REPEAT_BEGINNING_RULE", "PERSIAN_WORD_REPEAT_RULE", "PL_COMPOUNDS", "PL_SIMPLE_REPLACE", "PL_UNPAIRED_BRACKETS", "PL_WORD_REPEAT", "PUNCTUATION_GENERIC_CHECK", "PUNCTUATION_PARAGRAPH_END", "PUNCTUATION_PARAGRAPH_END2", "RAAN", "READABILITY_RULE_DIFFICULT", "READABILITY_RULE_SIMPLE", "ROMANIAN_WORD_REPEAT_BEGINNING_RULE", "RO_COMPOUND", "RO_SIMPLE_REPLACE", "R_WORDS", "SAME_TRANSLATION", "SENTENCE_WHITESPACE", "SE_CXU", "SIMPLE_REPLACE", "SITAGATTE_END", "SON_T", "SPACE_BEFORE_CONJUNCTION", "SPANISH_WORD_REPEAT_RULE", "SPANISH_WRONG_WORD_IN_CONTEXT", "STEVILA_DO_10", "STYLE_REPEATED_WORD_RULE", "SV_COMPOUNDS", "SYMSPELL_RULE", "TOO_LONG_PARAGRAPH", "TOO_LONG_SENTENCE", "TRANSLATION_LENGTH", "UKRAINIAN_WORD_REPEAT_RULE", "UK_ADJ_NOUN_INFLECTION_AGREEMENT", "UK_HIDDEN_CHARS", "UK_MISSING_HYPHEN", "UK_NOUN_VERB_INFLECTION_AGREEMENT", "UNPAIRED_BRACKETS", "UPPERCASE_SENTENCE_START", "WHITESPACE_PARAGRAPH", "WHITESPACE_PARAGRAPH_BEGIN", "WHITESPACE_PUNCTUATION", "WHITESPACE_RULE", "WOAGARU", "WORD_REPEAT_BEGINNING_RULE", "WORD_REPEAT_RULE", "WRONG_WORD_IN_CONTEXT" ] } ] } ] }
You will receive the list of grammar rules by calling this API.
As a response of the API server, you will receive JSON-encoded data containing a tasks
array with the information specific to the set tasks.
Field name | Type | Description |
---|---|---|
version |
string | the current version of the API |
status_code |
integer | general status code you can find the full list of the response codes here |
status_message |
string | general informational message you can find the full list of general informational messages here |
time |
string | execution time, seconds |
cost |
float | total tasks cost, USD |
tasks_count |
integer | the number of tasks in the tasks array |
tasks_error |
integer | the number of tasks in the tasks array returned with an error |
tasks |
array | array of tasks |
id |
string | task identifier unique task identifier in our system in the UUID format |
status_code |
integer | status code of the task generated by DataForSEO; can be within the following range: 10000-60000 you can find the full list of the response codes here |
status_message |
string | informational message of the task you can find the full list of general informational messages here |
time |
string | execution time, seconds |
cost |
float | cost of the task, USD |
result_count |
integer | number of elements in the result array |
path |
array | URL path |
data |
object | contains the parameters passed in the URL of the GET request |
result |
array | array of results |
rules |
array | array of rules |