Ghana Stock Exchange API

Last updated: August 7, 2014 at 19:22 GMT Created: 10 months, 3 weeks ago

IMAGE: Ghana Stock Exchange API
Reliable platform to query real-time GSE market data from

Once upon a time, I was looking for an API for the Ghana Stock Exchange to build an app which I don't even remember what it was about. After being tremendously disappointed that no such thing existed, I threw the idea into the Ghanaian ocean and went home to eat yorkor gari and shitor. Last week, I stumbled upon Selasie Agbavor's Python API for Ghana Stock Exchange. I liked his implementation although it is a bit fallible. (See lines 18-19 and 25-30.) Then I said to myself, Why don't you develop a real API for that? So I picked up my hoe and cutlass, and proceeded to build the first ever Ghana Stock Exchange API. Yay! (I doubt Selasie will join the cheer.)

Here are some questions I think you might ask, and may want to get straight answers to:

  • Where do you get the data from? I scrape them from the official website, gse.com.gh.
  • How often is the database updated? In real-time, using cron jobs and a secret protocol.
  • Is the code publicly available? Currently no, but hopefully, shortly will be.
  • For how long will this API be live? For as long as GSE shares the market data online.
  • Wud u rite da codez 4 ma PHP 4 me? No, unless you become a mummified Pharaoh.

Overview

This GSE API provides a reliable and consistent platform to query real-time trading statistics, in-depth market data and analysis, and authentic company information from the Ghana Stock Exchange. Also, it allows you to quickly and easily integrate the stock exchange's market data into your application, by launching simple HTTP requests. It is fast and easy to interact with. You don't need to sign up for any authentication keys before you can start using it. It's a free public web service! This webpage serves as the official documentation destination for the API. You may want to check out this GSE Live application that I've written to consume the API.

The API's request endpoint is http://dev.kwayisi.org/apis/gse. Currently, the response data format is available only in JSON and JSONP, however, support for XML and other data formats is being considered. When launching a request, you may append a prettify query string parameter to the URI to get the response in human readable layout. (For instance, http://dev.kwayisi.org/apis/gse/live?prettify.) One noteworthy thing is that, although some properties of the API objects are stated to be of type "float," their values may sometimes appear as integers, i.e. without decimal places. This anomaly may be corrected later.

Following are the various API resources and objects you should know about.

GET /live

This API resource returns an array of equity_live objects, representing the real-time trading data for each symbol listed on the Ghana Stock Exchange.

Example request:

http://dev.kwayisi.org/apis/gse/live

Example response:

[
   {
       "change": 1.59,
       "name": "ABC",
       "price": 10.52,
       "volume": 230
   },
   {
       "change": -0.05,
       "name": "DEF",
       "price": 1.06,
       "volume": 1040
   },
   {
       "change": 0.01,
       "name": "GHI",
       "price": 37.17,
       "volume": 542
   }
]

GET /live/{symbol}

This API resource returns an equity_live object, representing the real-time trading data for {symbol} on the Ghana Stock Exchange. If the specified ticker symbol is not found, an HTTP 404 status response is triggered.

Example request:

http://dev.kwayisi.org/apis/gse/live/abc

Example response:

{
   "change": 1.59,
   "name": "ABC",
   "price": 10.52,
   "volume": 230
}

GET /equities

This API resource returns an array of equity_live objects without the "change" and "volume" properties, representing a summary of each equity listed on the Ghana Stock Exchange.

Example request:

http://dev.kwayisi.org/apis/gse/equities

Example response:

[
   {
       "name": "ABC",
       "price": 10.52
   },
   {
       "name": "DEF",
       "price": 1.06
   },
   {
       "name": "GHI",
       "price": 37.17
   }
]

GET /equities/{symbol}

This API resource returns an equity object, representing in-depth market and company data for {symbol} on the Ghana Stock Exchange. If the specified ticker symbol is not found, an HTTP 404 status response is triggered.

Example request:

http://dev.kwayisi.org/apis/gse/equities/abc

Example response:

{
   "capital": 567.22,
   "company": {
       "address": "P. O. Box 123, Accra",
       "directors": [
           {
               "name": "Kofi Abanga",
               "position": "Chairman"
           },
           {
               "name": "Ama Nantwie",
               "position": null
           }
       ],
       "email": "abc@example.com",
       "facsimile": "+233 (302) 123 456",
       "industry": "Mining",
       "name": "ABC Company Ltd.",
       "notes": "Merged with XYZ company.",
       "sector": "Basic Materials",
       "telephone": "+233 (302) 123 789",
       "website": "www.example.com"
   },
   "dps": 0.077,
   "eps": 0.17,
   "name": "ABC",
   "price": 10.52,
   "shares": 36.5
}

Equity object

PropertyTypeNullableDescription
capitalfloatYesMarket capitalization (in GHS millions).
companyobjectNoIssuing company. (Instance of company.)
dpsfloatYesDividend per share.
epsfloatYesEarnings per share.
namestringNoTicker symbol.
pricefloatNoShare price.
sharesfloatYesTotal issued shares (in millions).

Equity_Live object

PropertyTypeNullableDescription
changefloatNoPrice change.
namestringNoTicker symbol.
pricefloatNoShare price.
volumeintegerNoVolume of shares traded.

Company object

PropertyTypeNullableDescription
addressstringYesPostal address of company.
directorsobjectNoBoard of directors. (Array of director instances.)
emailstringYesEmail address.
facsimilestringYesFacsimile number.
industrystringYesICB/GICS industry classification.
namestringNoName of company.
notesstringYesSummary of company profile.
sectorstringYesICB/GICS sector classification.
telephonestringYesTelephone number.
websitestringYesWebsite address.

Director object

PropertyTypeNullableDescription
namestringNoFull name.
positionstringYesJob title.

Comments (2)

PHOTO: Joe DjamasiJoe Djamasi August 28, 2014 at 05:02 GMT

Great stuff. Keep up the good work.
I consistently use tis API to check on the prices of my shares. Absolutely much better than the other official sites.

PHOTO: Michael KwayisiMichael Kwayisi August 28, 2014 at 07:53 GMT

Hello Joe. Thanks for your encouraging comment albeit a bit flattering :)

All the same, quite a pretty nice site you got there for yourself. Looking forward to learning more about the 'IT niche' you hope to create in Ghana as well. In the meantime, keep on 'bringing tranquility to stormy situations' and holding up all other things - "with a smile" :)

More: Related content

  1. IMGKwayisi's Application Development Center

    Kwayisi's Application Development Center
  2. IMGAfrican Stock Exchanges Live

    Stock quotes and trading information for African Exchanges
  3. IMGWeb Application Programming Interfaces

    Web Application Programming Interfaces
Copyright © 2014 Michael Kwayisi