Skip to content

Latest commit

 

History

History
202 lines (168 loc) · 6.77 KB

API.md

File metadata and controls

202 lines (168 loc) · 6.77 KB

TheDailyWTF API

Version

0.1

Notes

  • Refer ArticleModel class for description of terms used below.
  • The API returns data in JSON format with content type application/json.
  • Wherever applicable the count parameter has been limited to 100. The command shall return the specified count or the maximum available number of article (whichever is lesser).
  • The commands return a Status field specifying exceptions if any.
  • The API supports two types of commands : Listing Commands and Display Commands
  • Listing Commands
    • Return a list of articles in a json array.
    • The BodyHtml, BodyAndAdHtml and FooterAdHtml attributes of each ArticleModel object are replaced with an empty string.
    • This was done to reduce the amount of data returned during calls to get data to populate lists.
  • Display Commands
    • These commands get all the information about a specific article.
    • They also have parameters to allow return of only BodyHtml and FooterAdHtml attributes of ArticleModel object, to complete the information obtained from a listing command, for any particular valid article.
  • Base url for any api command shall be http://thedailywtf.com/api to which the below mentioned commands must be concatenated.

Bugs/Requests

Please create a new issue here

Commands

Display Commands

1. /articles/id/{id}

  • Description
    • Returns the article with the specified id
  • Parameters
    • id : integer : Unique identifier of the article
  • Example
  • Exceptions
    • { "Status": "Invalid Id" }
    • { "Status": "JSON Serialization Error : " }

2. /articles/id/{id}/{onlyBodyAndAdHtml}

  • Description
    • Returns only the BodyHtml and FooterAdHtml attributes of the article with the specified id
  • Parameters
    • id : integer : Unique identifier of the article
    • onlyBodyAndAdHtml : bool : Default value is false.
  • Example
  • Exceptions
    • { "Status": "Invalid Id" }
    • { "Status": "JSON Serialization Error : " }

3. /articles/slug/{articleSlug}

4. /articles/slug/{articleSlug}/{onlyBodyAndAdHtml}

  • Description
    • Returns only the BodyHtml and FooterAdHtml attributes of the article with the specified article slug
  • Parameters
    • articleSlug : string : Article Slug
    • onlyBodyAndAdHtml : bool : Default value is false.
  • Example
  • Exceptions
    • { "Status": "Invalid Article Slug" }
    • { "Status": "JSON Serialization Error : " }

5. /articles/random

Listing Commands

6. /articles/recent

7. /articles/recent/{count}

  • Description
    • Returns an array of {count} number of recent articles
  • Parameters
    • count : int
  • Example
  • Exceptions
    • { "Status": "Service Unavailable" }
    • { "Status": "Count cannot be greater than 100" }
    • { "Status": "JSON Serialization Error : " }

8. /articles/{year}/{month}

  • Description
    • Returns an array of articles published in the specified month of the specified year
  • Parameters
    • year : int : ideally > 1999
    • month : int : 1-12
  • Example
  • Exceptions
    • { "Status": "No articles found for the current date range" }
    • { "Status": "JSON Serialization Error : " }

9. /series/{slug}

  • Description
    • Returns an array of 8 recent articles in the series specified in {slug}
  • Parameters
    • slug : string : eg. code-sod, errord, feature-articles
  • Example
  • Exceptions
    • { "Status": "Invalid Series" }
    • { "Status": "JSON Serialization Error : " }

10. /series/{slug}/{count}

  • Description
    • Returns an array of {count} number of recent articles in the series specified in {slug}
  • Parameters
    • slug : string : eg. code-sod, errord, feature-articles
    • count : int
  • Example
  • Exceptions
    • { "Status": "Invalid Series" }
    • { "Status": "Count cannot be greater than 100" }
    • { "Status": "JSON Serialization Error : " }

11. /series/{slug}/{year}/{month}

  • Description
    • Returns an array of articles published in the specified month of the specified year in the specified series
  • Parameters
    • slug : string : eg. code-sod, errord, feature-articles
    • year : int : ideally > 1999
    • month : int : 1-12
  • Example
  • Exceptions
    • { "Status": "No articles found for the current date range or Invalid Series" }
    • { "Status": "JSON Serialization Error : " }

12. /author/{slug}

  • Description
    • Returns an array of 8 recent articles by the author specified in {slug}
  • Parameters
    • slug : string : eg. alex-papadimoulis, remy-porter
  • Example
  • Exceptions
    • { "Status": "Invalid Author" }
    • { "Status": "JSON Serialization Error : " }

13. /author/{slug}/{count}

  • Description
    • Returns an array of {count} number of recent articles by the author specified in {slug}
  • Parameters
    • slug : string : eg. alex-papadimoulis, remy-porter
    • count : int
  • Example
  • Exceptions
    • { "Status": "Invalid Author" }
    • { "Status": "Count cannot be greater than 100" }
    • { "Status": "JSON Serialization Error : " }

14. /series/