+ Reply Thread
#1

This is just to notify people to watch out for our legacy API. This is just a rather straight forward API to use for development. 

#2

I Ok Ayam not waiting

#3
i am waiting....
#4
@dhtml I see what you've done with this forum from last time I visited, very cool


#5

Authentication:

Let us start with logging in a user

You need to do this:

URL: https://api.africoders.com/v1/user/login

Post 2 parameters:

name  - The name can the username of the person (or email address)
password - The password of the person

So in essence, something like this: https://api.africoders.com/v1/user/login?name=wale&password=xylophone


Registering an account:

You need to post the following parameters to
URL: https://api.africoders.com/v1/user/signup
name=username e.g. dhtml
password=password of account
email=email address of the account


#6

Fetching Data From The Various Categories

We are going to be looking at how to fetch data (rather than scrap) from the various areas of the website.

Categories

As far as Africoders as concerned, most contents fall under post and comment, what differentiate them is the categories they fall into.

As at the time of this writing, we have 6 categories:

1.article : this is not in active use for now. It is basically a content page designed to provide guidelines.
2. blog: a blog post that users can comment upon. Any registered user can create a blog post.
3. forum : a forum thread that any registered user can create, and users can comment upon it.
4. job : a job advert post, similar to the blog in every way but in the jobs section.
5. link : a shared link, similar to the blog in every way but in the links section.
6. status : this is the status feed on the home page. Again, a registered user can share and users can comment on it.


Fetching the status feeds With Pagination

The recommended way to fetch the status feed is this:
https://api.africoders.com/v1/posts?category=status&include=comment:order(id|asc)&order=published_at|desc&limit=10

Let us analyze this url a bit.
category = this specifies any of the 6 categories you are interested in fetching
include = this specify that comments should be fetched with the post and the comments are to be sorted by the ID column and arranged in ascending order 
order = the order column/direction for the statuses themselves. published_at is the filter that allows you to retrieve the content in the way it is listed in the homepage. The status with the last comment/activity will bubble to the top, that is what changes the published_at
limit = this is the limit of data you wish to retrieve, if you want to retrieve 20 posts at a time, change that limit to 20

Based on the above explanation, if you want to fetch just the posts without any comment, use this:

https://api.africoders.com/v1/posts?category=status&order=published_at|desc&limit=10


To fetch the next page, you need to do something like this:

https://api.africoders.com/v1/posts?category=status&include=comment:order(id|asc)&order=published_at|desc&limit=10&page=2

or

https://api.africoders.com/v1/posts?category=status&order=published_at|desc&limit=10&page=2

You can just increment this until you get an empty data set, that is the best way to paginate


To fetch a single post with comment, you will need the post ID, then you can do the following:

https://api.africoders.com/v1/post?id=750&include=comment

To fetch a single post without comment, you will need the post ID, then you can do the following:

https://api.africoders.com/v1/post?id=750


How To Fetch Blog Posts

This is similar to the statuses

https://api.africoders.com/v1/posts?category=blog&include=comment:order(id|asc)&order=id|asc&limit=10

To fetch a single post is the same as for statuses, and for any other category of post.

How to fetch job adverts

https://api.africoders.com/v1/posts?category=job&include=comment:order(id|asc)&order=id|asc&limit=10


How to fetch link shares

https://api.africoders.com/v1/posts?category=link&include=comment:order(id|asc)&order=id|asc&limit=10


#7

Let us take a look at the forums:


Retrieving The Forum Listing

https://api.africoders.com/v1/forums

From the list returned, you will see the various paths of forums e.g. forums/php for the forums board i.e. https://africoders.com/forums/php


How To Retrieve A Board Without Comments

https://api.africoders.com/v1/forums/php?order=updated_at|DESC

Notice that the order for forum is slightly different from the status e.t.c this is because a forum board here is ordered by the last updated thread.


How To Retrieve A Board With Comments

https://api.africoders.com/v1/forums/php?order=updated_at|DESC&include=comment


How To Fetch A Single Thread
A thread such as Php sitemap generator can be retrieved like below based on our earlier lesson:
https://api.africoders.com/v1/post?id=745


To Fetch A Single Thread With Comments
https://api.africoders.com/v1/post?id=745&include=comment
#8

To be continued, if you have any question, please do not hesitate to ask.

#9
I'm just vexing in a funny way tho.... Why use this kinda format.... 2018-12-02 07:50:58.000000 instead of the normal php timestamp we know ?
#10

the timestamp mad gan ni o, you be programmer, you fit reformat am.

#11
I can reformat php timestamp both in php and java, the php own is quite simple but java has a little tweak.... But not to worry, I think the one on the api is UTF format, I can also reformat it, its just going to break my sweat I might even use relative time format.... That 2 minutes ago stuff, and I might not if its not communicating with me
#12

Me i no go talk anything o, just do good work so that you will not win 1k last last.

#13
I'll reformat it...lol Can you see that there isn't an api we can use to post stuffs.... Like post status or blog post or forum post or job..... Let's leave it that way biko, peace
#14
Yes please, let us leave it like that, no posting, I canno comman kee myself
#15
Its not even hard at all.... Just make a request to the api with parameters... its easier than getting json data and sorting it out
#16
@dhtml, on the forum board listing, what does "fid", "pid" & "tid" mean?
#17

Hey, API to post stuffs will be released by tomorrow night. I apologize for that, I am working on the security a bit and need to reach a conclusion myself.

The pid and tid are very important questions.

fid - forum id
pid - parent id
tid - ? where you take see that one?

#18
Lol.. there's tid there.. pls, can you explain the forum part further just like the Status part too? Thanks
#19

The TID is the ID of the forum board e.g. 79 is the ID of the chats board. forums\/xhtml has a tid of 11.

The TID and FID are the same, anyhow they are used.


#20

Let us Learn How To Post With The API


Remember our Categories

1.article : this is not in active use for now. It is basically a content page designed to provide guidelines.
2. blog: a blog post that users can comment upon. Any registered user can create a blog post.
3. forum : a forum thread that any registered user can create, and users can comment upon it.
4. job : a job advert post, similar to the blog in every way but in the jobs section.
5. link : a shared link, similar to the blog in every way but in the links section.
6. status : this is the status feed on the home page. Again, a registered user can share and users can comment on it.


Authorization

There are some requests such as posting stuffs with a user account, you need to authorize your request by adding 2 headers:

Accept = application/json

Authorization = Bearer dHdUZ2FNMXo2MWZrR3BjMjVlQ01CSUo4eGdCRVI3Q0VZS0pXd2htbg==

where dHdUZ2FNMXo2MWZrR3BjMjVlQ01CSUo4eGdCRVI3Q0VZS0pXd2htbg== is an example of a token generated during signin/signup.

This is why you are expected to keep the token after a successful authorization.


To post a status

You need to post the following parameter to

URL: https://api.africoders.com/v1/post/status

Parameter:

body=Welcome to Africoders 

* This requires authorization


To post a blog

You need to post the following parameters to

URL: https://api.africoders.com/v1/post/blog

Parameters:

title=Welcome to My Awesome Blog

body=Hi everyone, you are most welcome to my wonderful blog

* This requires authorization


To post a job

You need to post the following parameters to

URL: https://api.africoders.com/v1/post/job

Parameters:

title=I need a python developer

body=If you are a python developer and is available for a job here

* This requires authorization


To post a link

You need to post the following parameters to

URL: https://api.africoders.com/v1/post/link

Parameters:

title=Google search

body=You can search for anything here

url = https://google.com

* This requires authorization


To Post a forum topic

You need to post the following parameters to

URL: https://api.africoders.com/v1/post/forum

Parameters:

title=How To Write JAVA

body=You can write JAVA by learning how to use Netbeans

fid = 23

Note that fid is the ID of the forum, you will find this in the forum API.

* This requires authorization


To Post a comment to any post

No matter the type/category of post, posting comments is the same method

You need to post the following parameters to

URL: https://api.africoders.com/v1/comment

Parameters:

pid=23

body=You can write JAVA by learning how to use Netbeans

Note that pid is the ID of the post.

* This requires authorization


Back to top