The Loforo API can be used to interact with Loforo from your own application (web, mobile, server-based app, etc). Currently you can create posts via the API. More APIs will be added to retrieve existing posts, edit posts and more at a later time.
All Loforo APIs require an "API Key". You can get your API key from the Settings page when you are logged in. Note that the API key is site-specific so if you have multiple sites each site's API key will be different.
Do not share your API key with anyone or post it publicly -- the API key provides unrestricted access to your account/site (create, edit, delete, etc).
The API key should be sent with each API request (as input "key
")
There are 2 basic types of response you can expect from the API: a successful one or an error if something fails. Here are some sample responses:
{"status": 200, "success": true, "message": "Post created"}
{"status": 400, "success": false , "message": "Missing 'content'"}
You can use the API to create new posts on your site. The content of the post should be HTML formatted. You can also upload a picture or video to be inserted in your post with this API.
https://loforo.com/api/post/create
POST
key
(required): The API key (see API key section above)content
(required): Text / HTML content of your posttitle
(optional): Title of your postmedia
(optional): Can be used to upload and attach a photo or video with your post -- must be sent as multipart/form-data
data. See below for detailsstatus
(optional): Whether the post should be Published immediately (`0` - default), Draft (`1`), or Queued (`2`) to be published on a schedule (see settings)There are 2 ways to attach media (photos/videos) with your post.
If you embed 1 or more links to an image or video in the HTML content
of the post (with img
or video
tags), Loforo will display it within the post. If it's hosted on an external site, we will also mirror it to our servers shortly after the post is created.
If you want to upload an image or video from your own computer, you can use the media
input in the API mentioned above. Media can be up to 100MB and a single image/video can be attached per post at this time.
If you are uploading an image or video with your post, the media data must be in the multipart/form-data
format (HTML forms are sent this way for example).
Warning: The sample requests below contain your unique API key in them -- do not share them with others.
If you have curl
installed on your computer (most Mac and Linux computers do), you can upload from the command line/terminal as follows:
curl -d 'key=YOUR-API-KEY-HERE' -d 'title=Hello' -d 'content=<p>Hello World</p>' https://loforo.com/api/post/create
curl -d 'key=YOUR-API-KEY-HERE' -d 'content=<img src="https://example.com/image.jpg">' https://loforo.com/api/post/create
curl -d 'key=YOUR-API-KEY-HERE' -F 'media=@MyTestPicture.jpg' -d 'content=<p>A picture is attached to this post</p>' https://loforo.com/api/post/create
The following code will create a post with an image with Python using the requests
library (change the image name as needed):
import requests url = 'https://loforo.com/api/post/create' payload = { 'key': 'YOUR-API-KEY-HERE', 'content': '<p>A picture is attached to this post</p>' } files = {'media': open('IMAGE_NAME_HERE.jpg', 'rb')} print('Creating post..') response = requests.post(url, data=payload, files=files) print('HTTP Code:', response.status_code) print('Response Body:', response.text)
There are currently no hard rate limits on requests. We ask that you be responsible using this API and keep the number of simultaneous requests low and don't send too many requests rapidly. We reserve the right to disable your API and site access if we feel there is abuse.
If you have any questions, issues, or feature-requests, please contact us -- we'll be happy to help!