API

The TYPOGRAFFIT API

Table of Contents

 

 

1 Introduction

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 functions

– 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 behavior

First, view the URL below using internet browser.
http://api.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://api.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 script

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 plugin (Currently discontinued after 2012)

– We have WordPress plugin available.
– It will run under WordPress 2.5 and above.
– By surrounding the text with “….“, 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 protocol

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 Rules

Each URL of the TYPOGRAFFIT functions will be as follows.
http://api.typograffit.com/rest_json/[resource]/[action]
When handling data over HTTP GET method, it will be shown like this.
http://api.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 value

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 authentication

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 MOOD

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/register
registering Email / Username / PWD

HTTP Method
GET
params
email as String
password as String
username as String
returns
(Boolean) or error

ex.) http://api.typograffit.com/rest_json/users/register/email:info@example.com/password:testtest/username:TestUser


3.2 users/login

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 published.

ex.) http://api.typograffit.com/rest_json/users/login/email:info@example.com/password:testtest


3.3 users/edit

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://api.typograffit.com/rest_json/users/edit/email:info@example.com/password:testtest/username:TestUser/token:4a834f8e-273c-4550-9424-01c2d2fd7859


3.4 users/logout

logging out and discarding the token. (only for logged in users)
HTTP Method
GET
params
token as String
returns
(Boolean) or error
ex.) http://api.typograffit.com/rest_json/users/logout/token:4a834f8e-273c-4550-9424-01c2d2fd7859

4 Message Methods


4.1 posts/generate

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://api.typograffit.com/rest_json/posts/generate/token:4a834f8e-273c-4550-9424-01c2d2fd7859/body:test%20string%20blahblahblahblahblah/line_width:300

ex2.) http://api.typograffit.com/rest_json/posts/generate/body:test%20string%20blahblahblahblahblah/no_wrap:1


4.2 posts/getImage

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://api.typograffit.com/rest_json/posts/getImage/post_id:qYqpTEu1nzSQ


4.3 posts/getInfo

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://api.typograffit.com/rest_json/posts/getInfo/post_id:qYqpTEu1nzSQ


4.4 posts/list

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://api.typograffit.com/rest_json/posts/list/token:4a834f8e-273c-4550-9424-01c2d2fd7859


4.5 posts/edit

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://api.typograffit.com/rest_json/posts/edit/token:4a834f8e-273c-4550-9424-01c2d2fd7859/post_id:qYqpTEu1nzSQ/private_use:false


4.6 posts/delete

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://api.typograffit.com/rest_json/posts/delete/token:4a834f8e-273c-4550-9424-01c2d2fd7859/post_id:qYqpTEu1nzSQ

5 Source Image Methods


5.1 sources/upload

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/getImage

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://api.typograffit.com/rest_json/sources/getImage/token:4a834f8e-273c-4550-9424-01c2d2fd7859/source_id:14001


5.3 sources/getInfo

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://api.typograffit.com/rest_json/sources/getImage/token:4a834f8e-273c-4550-9424-01c2d2fd7859/source_id:14001


5.4 sources/list

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://api.typograffit.com/rest_json/sources/list/token:4a834f8e-273c-4550-9424-01c2d2fd7859


5.5 sources/edit

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://api.typograffit.com/rest_json/sources/edit/token:4a834f8e-273c-4550-9424-01c2d2fd7859/source_id:14001/phrase:test%20phrase/private_use:false


5.6 sources/delete

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://api.typograffit.com/rest_json/sources/delete/token:4a834f8e-273c-4550-9424-01c2d2fd7859/source_id:14001

6 Error Messages

Error Messages for TYPOGRAFFIT REST API

 

Error Message
Error Code
Methods
Invalid URL. 01
Invalid token. 02
Undefined action. 03
Login required. 04 posts/list, posts/edit, posts/delete, sources/*, users/edit, users/logout
This E-mail is already registered. 05 users/register, users/edit
Username is empty. 06 users/register, users/edit
Username must be under 30 letters. 07 users/register, users/edit
E-mail is empty. 08 users/login, users/register, users/edit
E-mail must be under 255 letters. 09 users/register, users/edit
Invalid E-mail Address. 10 users/register, users/edit
Invalid email or password. 11 users/login
Password is empty. 12 users/login, users/register, users/edit
Password must be in between 5 – 20 letters. 13 users/register, users/edit
Body text is empty. 14 posts/generate
Body text must be under 1000 letters. 15 posts/generate
Post ID is empty. 16 posts/generate, posts/getInfo, posts/edit, posts/delete
Post ID is invalid. 17 posts/generate, posts/getInfo
Post not found. 18 posts/edit, posts/delete
Page does not exist. 19 posts/list, sources/list
Private Use is empty. 20 posts/edit, sources/edit
Image height is too short. 21 sources/upload
Image is empty. 22 sources/upload
Image upload error! 23 sources/upload
Image width is too long. 24 sources/upload
Invalid binary.Check the image is “jpeg”, “png” or “gif” format. 25 sources/upload
Source ID is empty. 26 sources/getImage, sources/getInfo, sources/edit, sources/delete
Source ID is invalid. 27 sources/getImage, sources/getInfo
Source not found. 28 sources/delete
Phrase is empty. 29 sources/upload, sources/edit
Phrase must be under 30 letters. 30 sources/upload, sources/edit
Invalid background color. 31 (Reserved)
Currently under sever maintainance. Please try again later. 32 (Reserved)
99 (Not in above. Reserved.)