A PHP API extension the 'An API of Ice and Fire'

Overview

Welcome to An Extended API of Ice & Fire

Documetation Page

Navigation

Documentation

Introduction

This documentation is meant to enable you to consume our API and get you started right away using your favourite programming language. All endpoints and HTTP methods to be used have been detailed with a sample example for each. A HTML format for this document is live at https://got-api-dsyengo.herokuapp.com/api/docs

Production Working React Based App

You can checkout the code repo on demo usage.

Requirements

  1. PHP 8.0 and above.
  2. PostgreSQL, MySQL or MariaDB server
  3. Composer dependency manager for PHP.
  4. Access to a terminal prompt (or any other means to access and edit the .env.example variables to match your setup).
  5. Git & Git Bash to run git commands.

Installation

  1. Clone this repository using the command
git clone https://github.com/syengo254/An-Extended-API-of-Ice-Fire.git
  1. Copy the .ev.example file and rename the copy to .env and edit the entry keys in the next step.
  2. Create a database named 'topup_mama' on your MySQL server. If the server is not local, edit the .env DB_HOST=127.0.0.1 entry to DB_HOST=; as well as DB_USERNAME & DB_PASSWORD keys.
  3. Navigate to the project folder and open a terminal window from that directory or use cd command.
  4. Run the composer update command to install all project dependencies
composer update
  1. Run the PHP artisan migration command
php artisan migrate
  1. Run the below command to finally run a deveopment PHP server to serve the project on http://localhost:8000/
php -S localhost:8000 -t public
  1. Access the URL endpoints as defined on the Endpoints section below.

Versioning

A a consumer of this API, versioning has been abstracted and need not to worry about it when making requests.

Endpoints

The following table below highlights the available endpoints, HTTP method and a description.

# Endpoint URL HTTP Verb Description
1. /api/books GET This will return a JSON response of an object with a list of all available books.
2. /api/books/1 GET This will return a JSON response of the book with and id of 1.
3. /api/books/1/comments GET This will return a JSON response of comments for the book with an id of 1.
4. /api/books/1/characters GET This will return a JSON response of the characters for the book with an id of 1.
5. /api/characters GET Returns a JSON response of all available book characters.
6. /api/characters/23 GET Return a JSON response with the character details with an id of 23.
7. /api/comments POST Send a POST request to this endpoint to add a comment for a particular book that is identified by its ISBN number. Required params are: 1. isbn - ISBN number - text, 1. comment - The comment text - limited to 500 characters

Note that the endpoint URL is to appended to the domain hosting the application i.e. if your domain is www.example.com, then the complelet endpoint URL will be www.example.com/api/books for the books GET path.

Response Structure

  • All responses for the endpoints defined will be in JSON format and a header for Content-Type: 'Application/json' will be sent.
  • All response objects with have an object named data that will hold the payload e.g. an array of characters or books, a book, a comment, etc.
  • All response objects with have an object named success that will hold either 1 representing success, 0 represnting failed and -1 representing and invalid request type.
  • Incase of an error, a data object named message will be included to show the specific error details.

See below example:

{
	"success": 1,
	"data": {
		"book": {
			"name": "A Game of Thrones",
			"isbn": "978-0553103540",
			"url": "http://localhost:8000/api/books/1",
			"comment_count": 1,
			"authors": [
			"George R. R. Martin"
			]
		},
		"comments": [
			{
			"id": 1,
			"isbn": "978-0553103540",
			"comment": "Best book I've ever read so far!",
			"user_ip": "192.168.100.10",
			"created_at": "2022-03-23 19:18:17"
			}
		]
	}
}

Pagination

Results for requests that respond with lists e.g. books' list and characters' list, will be paginated. You can make a request and specify a page and pageSize as GET URL parameters. The pagination links are also included by default in the JSON object response named "pages". The 'pages' object has links with the keys 'prev', 'first' & 'last' and a 'total_pages' object. You can use to create pagination for your app that will consume our API.

An example like below: ```CMD curl http://localhost:8000/api/books?page=2&pageSize=10

The results will look like below:
```JSON
{
	"success": 1,
	"data": [
		{
		"name": "The World of Ice and Fire",
		"isbn": "978-0553805444",
		"authors": [
		"Elio Garcia",
		"Linda Antonsson",
		"George R. R. Martin"
		],
		"released": "2014-10-28",
		"comments": [...]
		},
	...],
	"pages": {
		"prev": "http://localhost:8000/api/books?page=1&pageSize=10",
		"first": "http://localhost:8000/api/books?page=1&pageSize=10",
		"last": "http://localhost:8000/api/books?page=2&pageSize=10",
		"total_pages": 2
	}
}

Result Filters

You can specify filters via URL GET params for specific results. Available filters for every resource are listed in the next section.

Usage

1. Books

curl "http://localhost:8000/api/books"
Available filters: _\_ `e.g. http://localhost:8000/api/books?name=A Game of Thrones` This will return:
```JSON
	{
		"success": 1,
		"data": \[
		{
		"name": "A Game of Thrones",
		"isbn": "978-0553103540",
		"authors": \[
		"George R. R. Martin"
	...}
```
  • To get the details of a particular book, make a GET request to the URL: http://localhost:8000/api/books/ Replace with an integer representing the books id e.g. 1, 2, 3, ... as show below:
curl "http://localhost:8000/api/books/23"

2. Book Characters

curl "http://localhost:8000/api/characters"

Available filters: , , e.g. http://localhost:8000/api/characters?name=Nysterica This will return: JSON { "success": 1, "data": [ { "url": "http://localhost:8000/api/characters/21", "name": "Nysterica", "gender": "Female", ...} ...], ...}, "metadata": { "matched_count": 1, "total_age": {...} }, "pages": {...} } Another example: curl http://localhost:8000/api/characters?gender=Female

  • To get the details of a particular character, make a GET request to the URL: http://localhost:8000/api/characters/ Replace with an integer representing the characters id e.g. 1, 2, 3, ... as show below:
curl "http://localhost:8000/api/characters/2"
  • To get a list of all characters in a particular book e.g. 2, make a GET request to the URL: http://localhost:8000/api/books//characters Replace with an integer representing the characters id e.g. 1, 2, 3, ... as show below:
curl "http://localhost:8000/api/books/2/characters"

Available filters: , e.g. http://localhost:8000/books/2/characters?name=Nysterica e.g. http://localhost:8000/books/2/characters?gender=Female

All character list request are sortable by name in both ascending and descending order. This can be specified via GET URL params: & e.g. http://localhost:8000/characters?gender=Male&sortby=name&order=desc e.g. http://localhost:8000/books/2/characters?page=12&pageSize=7&sortby=name&order=asc Default sort order will default to asc (ascending) if not specified.

3. Book Comments

  • To get a list of all comments made for a particular book, make an HTTP GET request to: http://localhost:8000/api/books//comments Replace with a book id e.g. 1, 2, 3, etc. Example:
curl "http://localhost:8000/api/books/2/comments"
The above command will return a list of comments for the book with an id of 2.
  • To add a comment to a particular book, send your POST request to the URL: http://localhost:8000/api/comments and include the parameters isbn and comment.
    Both isbn and comment parameters should of type string and the isbn should be valid for a particular book. The comment parameter is limited to a maximum of 500 characters.
    Generally, a POST request is sent via an HTML form. The data send to the form is usually encoded in either multipart/form-data, application/json or application/x-www-form-urlencoded content type.

Limitations

You can unlimited requests in a day to the API as long you don't exceed 60 requests per minute. Exceeding this minute limit will have your requests rejected for a preiod of 5 minutes.

Licensing & Copyright

We make no ownership of the data we provide via our API. This is an API extension of the 'AN API OF ICE AND FIRE' by Joakim Skoog.
More details on the API are available at AN API OF ICE AND FIRE

This project uses a MIT license.

© 2022 - David Syengo. GitHub profile link icon

Lumen PHP Framework

Build Status Total Downloads Latest Stable Version License

Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Lumen attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as routing, database abstraction, queueing, and caching.

License

The Lumen framework is open-sourced software licensed under the MIT license.

You might also like...
With the phpBB extension "Hide for Guest" you can hidden selected areas for guests and bots.

phpBB-Hide for Guest Description With "Hide for guest" selected areas are hidden for guests and bots. Requirements php 7.3 or higher phpBB 3.2.0 or hi

Enabling community-powered extension and improvements of the best time indications given.
Enabling community-powered extension and improvements of the best time indications given.

Enabling community-powered extension and improvements of the best time indications given.

An opinionated extension package for Laravel Orchid to extend its table handling capabilities, and some further useful helper methods.
An opinionated extension package for Laravel Orchid to extend its table handling capabilities, and some further useful helper methods.

OrchidTables An opinionated extension package for Laravel Orchid to extend its table handling capabilities, and some further useful helper methods. In

Magento 2 GDPR extension Free by Magepow helps websites comply with GDPR regulations, allowing customers to control personal data and avoid penalties.

Magento 2 GDPR extension Free by Magepow helps websites comply with GDPR regulations, allowing customers to control personal data and avoid penalties.

PHPStan extension for sealed classes and interfaces.

Sealed classes with PHPStan This extension adds support for sealed classes and interfaces to PHPStan. Installation To use this extension, require it v

This extension links MediaWiki to phpBB's user table for authentication, and disallows the creation of new accounts in MediaWiki.

This extension links MediaWiki to phpBB's user table for authentication, and disallows the creation of new accounts in MediaWiki. Users must then log in to the wiki with their phpBB account.

A simple and easy-to-use enumeration extension package to help you manage enumerations in your project more conveniently

A simple and easy-to-use enumeration extension package to help you manage enumerations in your project more conveniently

OctoberCMS BlogHub Plugin - Extends RainLab's Blog extension with custom meta details, additional archives and more.

BlogHub extends the RainLab.Blog OctoberCMS plugin with many necessary and helpful features such as Moderatable Comments, Promotable Tags, Custom Meta Fields, additional Archives, basic Statistics, Views counter and more.

Generate stubs for any PHP extension.

php-ext-stubs-generator Installation Run $ composer require --dev lctrs/php-ext-stubs-generator Usage $ php vendor/bin/generate-stubs-for-ext extensio

Owner
David Syengo
David Syengo
Magento 2 Extension to cleanup admin menu and Store > Configuration area by arranging third party extension items.

Clean Admin Menu - Magento 2 Extension It will merge all 3rd party extension's menu items in backend's primary menu to a common menu item named "Exten

RedChamps 109 Jan 3, 2023
Magento 2 Blog Extension is a better blog extension for Magento 2 platform. These include all useful features of Wordpress CMS

Magento 2 Blog extension FREE Magento 2 Better Blog by Mageplaza is integrated right into the Magento backend so you can manage your blog and your e-c

Mageplaza 113 Dec 14, 2022
JSONFinder - a library that can find json values in a mixed text or html documents, can filter and search the json tree, and converts php objects to json without 'ext-json' extension.

JSONFinder - a library that can find json values in a mixed text or html documents, can filter and search the json tree, and converts php objects to json without 'ext-json' extension.

Eboubaker Eboubaker 2 Jul 31, 2022
Backwards compatibility Extension and Library for PHP 8.x and later

colopl_bc Provides various compatibility functions required for PHP (temporary) migration. WARNING This extension is intended for temporary use only.

COLOPL,Inc. 10 Jun 13, 2023
PHP Meminfo is a PHP extension that gives you insights on the PHP memory content

MEMINFO PHP Meminfo is a PHP extension that gives you insights on the PHP memory content. Its main goal is to help you understand memory leaks: by loo

Benoit Jacquemont 994 Dec 29, 2022
Okex API Like the official document interface, Support for arbitrary extension.

It is recommended that you read the official document first Okex docs https://www.okex.com/docs/en Okex Simulation Test API https://www.okex.com/docs/

lin 34 Jan 1, 2023
It's basically a dynamic web browser extension that can display notifications with the help of an admin-controlled dynamic API.

D-NOTIFIER A self controlled dynamic API based web browser extension built by Sahil Kumar How It Works? It's basically a dynamic web browser extension

Sahil Kumar 1 Jan 6, 2022
Magento 2 Megamenu extension is an indispensable component, and plays the role of website navigation to help customers easily categorize and find information

Mageno 2 Mega Menu (Magicmenu) helps you create neat and smart navigation menus to display the main categories on your website.

https://magepow.com 35 Dec 1, 2022
Magento 2 Blog is an extension that allows you to manage your store and blog

Magento 2 Blog Extension by Magefan Magento 2 Blog is an extension that allows you to manage your store and blog from one place without having to rely

Magefan 243 Dec 21, 2022
Composer Repository Manager for selling Magento 2 extension and offering composer installation for ordered packages.

Magento 2 Composer Repository Credits We got inspired by https://github.com/Genmato. Composer Repository for Magento 2 This extension works as a Magen

EAdesign 18 Dec 16, 2021