Categorization: Text API

AlchemyAPI provides easy-to-use facilities for categorizing from any textual content: Post (upload) any content directly to our service for analysis.

Posted content is analyzed and a categorization label is automatically assigned.

These API calls may be utilized to process posted (uploaded) textual content. If you are processing content hosted on a publicly accessible website, consider using our URL processing calls.

API Call: TextGetCategory

Description: The TextGetCategory call is utilized to categorize posted text document.

Endpoint: http://access.alchemyapi.com/calls/text/TextGetCategory

Parameters:

http argument parameter description
apikey your private api key

(required parameter)
text Text document content (must be uri-argument encoded)

(required parameter)
url Text document URL (must be uri-argument encoded)

(optional parameter, for response tracking purposes.)
outputMode desired API output format

Possible values:
xml (default)
json
rdf
rel-tag
rel-tag-raw

(optional parameter)
baseUrl rel-tag output base http url

(optional parameter, used with rel-tag or rel-tag-raw outputMode. must be uri-argument encoded)

Response Format (XML)

<results>
    <status>REQUEST_STATUS</status>
    <url>DOCUMENT_URL</url>
    <category>DETECTED_CATEGORY</category>
    <score>CATEGORY_SCORE</score>
</results>

Response Format (JSON):

{
    "status": "REQUEST_STATUS",
    "url": "DOCUMENT_URL",
    "category": "DETECTED_CATEGORY",
    "score": "CATEGORY_SCORE"
}

Response Format (RDF):

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                 xmlns:aapi="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#"
                 xml:base="http://rdf.alchemyapi.com/rdf/v1/r/response.rdf">
    <rdf:Description rdf:ID="DOCUMENT_HASH">
        <rdf:type rdf:resource="http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#DocInfo"/>
        <aapi:ResultStatus>REQUEST_STATUS</aapi:ResultStatus>
        <aapi:Language>DOCUMENT_LANGUAGE</aapi:Language>
        <aapi:URL>DOCUMENT_URL</aapi:URL>
        <aapi:DocCateg>DETECTED_CATEGORY</aapi:DocCateg>
        <aapi:CategScore>CATEGORY_SCORE</aapi:CategScore>
    </rdf:Description>
</rdf:RDF>

Response Format (REL-TAG Microformat [XML-embedded] ):

<results>
    <status>REQUEST_STATUS</status>
    <url>DOCUMENT_URL</url>
    <score>CATEGORY_SCORE</score>
    <microformats>
        <a href="REQUESTED_BASE_URL/DETECTED_CATEGORY" rel="tag">DETECTED_CATEGORY</a>
    </microformats>
</results>

Response Format (REL-TAG Microformat [raw] ):

<a href="REQUESTED_BASE_URL/DETECTED_CATEGORY" rel="tag">DETECTED_CATEGORY</a>

Response Fields:

field name field description
status success / failure status indicating whether the request was processed.

Possible values:
OK
ERROR
url http url specified in the API request.
category detected category.

Possible values: (click to see list)
score confidence score for the detected category 0.0 .. 1.0 (higher is better).
statusInfo failure status information (sent only if "status" == "ERROR").

Possible values:
invalid-api-key
page-is-not-html

API Notes:

  • 1. Calls to TextGetCategory should be made using HTTP POST.
  • 2. HTTP POST calls should include the Content-Type header: application/x-www-form-urlencoded
  • 3. Posted text documents can be a maximum of 150 kilobytes. Larger documents will result in a "content-exceeds-size-limit" error response.
  • 4. Language detection is performed on the retrieved document before attempting categorization. A minimum of 15 characters of text must exist within the requested HTTP document to perform language detection.
  • 5. Documents containing less than 15 characters of text are assumed to be English-language content.


 - return to top of page -