The TYPOGRAFFIT API

Table of Contents
  • 1 IntroductionBACK TO API TOP
  • TYPOGRAFFIT API will enable you to access TYPOGRAFFIT functions over website or network-enabled applications. To be specific user can TYPOGRAFF the text inputs of blog comments or posts. User are also able to use the custom image uploads, or image management console. Most of the TYPOGRAFFIT functions are available.
  • 1.1 Main functionsBACK TO API TOP
  • - Generate image through text.
    - Generate different types of "mood" of the image through the text input.
    - View, edit, delete, generated images (requires login).
    - Allows users to upload, edit, and delete image library (requires login).
  • 1.2 Basic behaviorBACK TO API TOP
  • First, view the URL below using internet browser.
    http://typograffit.com/rest_json/posts/generate/body:This%20is%20a%20test
    You will see a text string shown below.
    {"post_id":"U0JGIO2cWBKE"}
    The string "U0JGIO2cWBKE" will be the ID code for the generated image.
    Let's take a look at what kind of image has been generated.
    http://typograffit.com/rest_json/posts/getImage/post_id:U0JGIO2cWBKE
    *The ID code will be inserted after "post_id:".
    Generated image should appear in your browser.
  • 1.3 Easiest sample PHP scriptBACK TO API TOP
  • If you are able to use PHP, you can check the behavior by placing the sample file below.
    GitHub : Simple TYPOGRAFFIT API Sample
  • 1.4 TYPOGRAFFIT WordPress pluginBACK TO API TOP
  • - We have WordPress plugin available.
    - It will run under WordPress 2.5 and above.
    - By surrounding the text with "[typo]....[/typo]", it will TYPOGRAFF the text in between.
    - The TYPOGRAFFed image result will shown as single line inline within the text.
    TYPOGRAFFIT WordPress Plugin
  • 2 General specs
  • 2.1 Available API protocolBACK TO API TOP
  • Current API protocol will be REST-JSON. The request provided from client will be handled over HTTP GET or HTTP POST. The data type results from the server side will be given as JSON.
    Regarding to JSON, please read the URL below for further information.
    http://www.json.org/index.html
    TYPOGRAFFIT API is trying as much as possible to comply with REST-JSON, but there are some restrictions or partial extensions.
  • 2.2 URL RulesBACK TO API TOP
  • Each URL of the TYPOGRAFFIT functions will be as follows.
    http://typograffit.com/rest_json/[resource]/[action]
    When handling data over HTTP GET method, it will be shown like this.
    http://typograffit.com/rest_json/[resource]/[action]/[param1name]:[param1]/[param2name]:[param2]/...
    Please handle each parameter using URL encode. (Return-code also available.)
    Please use UTF-8 for the character code.
  • 2.3 Return valueBACK TO API TOP
  • The response given from the API will be in JSON format. The character code will be UTF-8.
    On error, the error code will be shown followed by the error message.
    {"error":"Body text must be under 1000 letters.","error_code":"15"}
    Please see section "6. Error messages" for further details.
  • 2.4 User authenticationBACK TO API TOP
  • User authentication is required for using some methods.
    By user authentication, you will able to use full function of the API we provide.
    In order to authenticate you will need to use the "Token" confirmed after "E-mail / Password". This can be issued after "/users/login" method.
  • 2.5 About MOODBACK TO API TOP
  • The images distributed over TYPOGRAFFIT will consist a meta-information called "Mood". Mood is a additional information for categorizing different image expressions (image feelings) . By re-generating the image results, user can change the "Mood". Please see "posts/generate" under section "4. Message methods" for further details.
  • 3 User Auth Methods
  • 3.1 users/registerBACK TO API TOP
  • registering Email / Username / PWD
  • HTTP Method
  • GET
  • params
  • email as String
    password as String
    username as String
  • returns
  • (Boolean) or error
  • ex.
  • http://typograffit.com/rest_json/users/register/email:info@example.com/password:testtest/username:TestUser
  • 3.2 users/loginBACK TO API TOP
  • logging in and getting token
  • HTTP Method
  • GET
  • params
  • email as String
    password as String
  • returns
  • (token as String, username as String) or error
  • note
  • Token will expire in 2 weeks after it have been pulished.
  • ex.
  • http://typograffit.com/rest_json/users/login/email:info@example.com/password:testtest
  • 3.3 users/editBACK TO API TOP
  • editing the user's own profile.
    (only for logged in users)
  • HTTP Method
  • GET
  • params
  • username as String
    email as String
    password as String
    token as String
  • returns
  • (Boolean) or error
  • ex.
  • http://typograffit.com/rest_json/users/edit/email:info@example.com/password:testtest/username:TestUser/token:4a834f8e-273c-4550-9424-01c2d2fd7859
  • 3.4 users/logoutBACK TO API TOP
  • logging out and discarding the token.
    (only for logged in users)
  • HTTP Method
  • GET
  • params
  • token as String
  • returns
  • (Boolean) or error
  • ex.
  • http://typograffit.com/rest_json/users/logout/token:4a834f8e-273c-4550-9424-01c2d2fd7859
  • 4 Message Methods
  • 4.1 posts/generateBACK TO API TOP
  • generating image from text
  • HTTP Method
  • GET
  • params
  • body as String
    token as String (optional)
  • use if the user has been logged in.
  • post_id as String (optional)
  • use when re-generating an image and rotating "mood".
  • no_wrap as Integer (optional)
  • if set to 1, the image will be generated as one line.
  • line_width as Integer (optional)
  • By default, the line width will be set to 800px.
  • returns
  • (post_id as String) or error
  • note
  • post_id is not an integer. It comes as unique strings such like 'qYqpTEu1nzSQ'
    Assign the previous "post_id" of the image in order to change "Mood".
    Make sure to assign the "token" issued on login, if you want to manage messages using "posts/list, posts/edit, posts/delete".
  • ex1.
  • http://typograffit.com/rest_json/posts/generate/token:4a834f8e-273c-4550-9424-01c2d2fd7859/body:test%20string%20blahblahblahblahblah/line_width:300
  • ex2.
  • http://typograffit.com/rest_json/posts/generate/body:test%20string%20blahblahblahblahblah/no_wrap:1
  • 4.2 posts/getImageBACK TO API TOP
  • getting image
  • HTTP Method
  • GET
  • params
  • post_id as String
    token as String (optional)
    max_width as Integer (optional)
  • If this value is set, the image will be resized.
  • max_height as Integer (optional)
  • If this value is set, the image will be resized.
  • returns
  • (jpeg image) or error
  • ex.
  • http://typograffit.com/rest_json/posts/getImage/post_id:qYqpTEu1nzSQ
  • 4.3 posts/getInfoBACK TO API TOP
  • getting info for the message
  • HTTP Method
  • GET
  • params
  • post_id as String
    token as String (optional)
  • returns
  • (body as String, width as Integer, height as Integer, private_use as Boolean) or error
  • ex.
  • http://typograffit.com/rest_json/posts/getInfo/post_id:qYqpTEu1nzSQ
  • 4.4 posts/listBACK TO API TOP
  • getting the user's message list.
    (only for logged in users)
  • HTTP Method
  • GET
  • params
  • page as Integer (optional)
  • starts from 1. By default, set to 1.
  • token as String
  • returns
  • (post_ids as Array, max_page as Integer) or error
  • note
  • It returns 10 items per page.
  • ex.
  • http://typograffit.com/rest_json/posts/list/token:4a834f8e-273c-4550-9424-01c2d2fd7859
  • 4.5 posts/editBACK TO API TOP
  • editing the properties about a message.
    (only for logged in users)
  • HTTP Method
  • GET
  • params
  • post_id as String
    private_use as Boolean
    token as String
  • returns
  • (Boolean) or error
  • ex.
  • http://typograffit.com/rest_json/posts/edit/token:4a834f8e-273c-4550-9424-01c2d2fd7859/post_id:qYqpTEu1nzSQ/private_use:false
  • 4.6 posts/deleteBACK TO API TOP
  • deleting a message.
    (only for logged in users)
  • HTTP Method
  • GET
  • params
  • post_id as String
    token as String
  • returns
  • (Boolean) or error
  • ex.
  • http://typograffit.com/rest_json/posts/delete/token:4a834f8e-273c-4550-9424-01c2d2fd7859/post_id:qYqpTEu1nzSQ
  • 5 Source Image MethodsBACK TO API TOP
  • 5.1 sources/uploadBACK TO API TOP
  • uploading image
  • HTTP Method
  • POST
  • params
  • image
    phrase as String
    token as String
  • returns
  • (Boolean) or error
  • note
  • As a general rule, uploaded images will be automatically resized their height by 80px.
    "image" must be posted by enctype "multipart/form-data".
  • 5.2 sources/getImageBACK TO API TOP
  • getting uploaded image
    (only for logged in users)
  • HTTP Method
  • GET
  • params
  • source_id as String
    token as String
  • returns
  • (jpeg image) or error
  • ex.
  • http://typograffit.com/rest_json/sources/getImage/token:4a834f8e-273c-4550-9424-01c2d2fd7859/source_id:14001
  • 5.3 sources/getInfoBACK TO API TOP
  • getting info for the uploaded images
    (only for logged in users)
  • HTTP Method
  • GET
  • params
  • source_id as String
    token as String
  • returns
  • (phrase as String, width as Integer, height as Integer, private_use as Boolean) or error
  • ex.
  • http://typograffit.com/rest_json/sources/getImage/token:4a834f8e-273c-4550-9424-01c2d2fd7859/source_id:14001
  • 5.4 sources/listBACK TO API TOP
  • getting the user's upload list.
    (only for logged in users)
  • HTTP Method
  • GET
  • params
  • page as Integer (optional)
  • starts from 1. By default, set to 1.
  • token as String
  • returns
  • (source_ids as Array, max_page as Integer) or error
  • note
  • It returns 10 items per page.
  • ex.
  • http://typograffit.com/rest_json/sources/list/token:4a834f8e-273c-4550-9424-01c2d2fd7859
  • 5.5 sources/editBACK TO API TOP
  • editing the properties about uploaded image.
    (only for logged in users)
  • HTTP Method
  • GET
  • params
  • source_id as String
    phrase as String
    private_use as Boolean
    token as String
  • returns
  • (Boolean) or error
  • ex.
  • http://typograffit.com/rest_json/sources/edit/token:4a834f8e-273c-4550-9424-01c2d2fd7859/source_id:14001/phrase:test%20phrase/private_use:false
  • 5.6 sources/deleteBACK TO API TOP
  • deleting a uploaded image.
    (only for logged in users)
  • HTTP Method
  • GET
  • params
  • source_id as String
    token as String
  • returns
  • (Boolean) or error
  • ex.
  • http://typograffit.com/rest_json/sources/delete/token:4a834f8e-273c-4550-9424-01c2d2fd7859/source_id:14001
  • 6 Error MessagesBACK TO API TOP
  • Error Messages for TYPOGRAFFIT REST API
  • Error MessageError CodeMethods
    Invalid URL.01-
    Invalid token.02-
    Undefined action.03-
    Login required.04posts/list, posts/edit, posts/delete, sources/*, users/edit, users/logout
    This E-mail is already registered.05users/register, users/edit
    Username is empty.06users/register, users/edit
    Username must be under 30 letters.07users/register, users/edit
    E-mail is empty.08users/login, users/register, users/edit
    E-mail must be under 255 letters.09users/register, users/edit
    Invalid E-mail Address.10users/register, users/edit
    Invalid email or password.11users/login
    Password is empty.12users/login, users/register, users/edit
    Password must be in between 5 - 20 letters.13users/register, users/edit
    Body text is empty.14posts/generate
    Body text must be under 1000 letters.15posts/generate
    Post ID is empty.16posts/generate, posts/getInfo, posts/edit, posts/delete
    Post ID is invalid.17posts/generate, posts/getInfo
    Post not found.18posts/edit, posts/delete
    Page does not exist.19posts/list, sources/list
    Private Use is empty.20posts/edit, sources/edit
    Image height is too short.21sources/upload
    Image is empty.22sources/upload
    Image upload error!23sources/upload
    Image width is too long.24sources/upload
    Invalid binary.Check the image is "jpeg", "png" or "gif" format.25sources/upload
    Source ID is empty.26sources/getImage, sources/getInfo, sources/edit, sources/delete
    Source ID is invalid.27sources/getImage, sources/getInfo
    Source not found.28sources/delete
    Phrase is empty.29sources/upload, sources/edit
    Phrase must be under 30 letters.30sources/upload, sources/edit
    Invalid background color.31(Reserved)
    Currently under sever maintainance. Please try again later.32(Reserved)
    - 99(Not in above. Reserved.)