Git Product home page Git Product logo

dinosaur-api's Introduction

Dinosaur API

This is an API to get information about dinosaurs. The API was created using the Laravel framework.

Getting Started

If you would like to contribute you can get started with this project by following these instructions:

  1. Clone the repo
git clone https://github.com/GeorgeBetts/Dinosaur-API.git
  1. Copy the ENV file and generate a key
cp .env.example .env
php artisan key:generate
  1. Install NPM & Composer packages
npm install
composer install
  1. Run database migrations and seeder
php artisan migrate
php artisan db:seed

Usage

The API follows standard REST resource structure. The resoures available in the API are:

  • Dinosaur

To interact with these resources the following endpoints are available:

  • GET /resource
  • GET /resource/{id}

E.g. to retrieve a list of Dinosaurs

http://localhost/api/dinosaurs

You can also filter the Dinosaurs resource using the following parameters:

Parameter Type Description
name String Search string to filter by dinosaur name
exact_match Bool Set to true if you want all String parameters to be an exact match of your search parameter
has_image Bool Set to true to only return records that have at least one image
has_article Bool Set to true to only return records that have at least one article
has_wikipedia_entry Bool Set to true to only return records that have a wikipedia entry

For example, to retrieve a list of dinosaurs where their name contains 'Stego', that have a wikipedia article and at least one image, you would use the following parameters:

http://localhost/api/dinosaurs?name=Stego&has_wikipedia_entry=true&has_image=true

To retrieve dinosaurs that match the exact name 'Stegosaurus':

http://localhost/api/dinosaurs?name=Stegosaurus&exact_match=true

You can also retrieve the Stegosaurus by using it's id:

http://localhost/api/dinosaurs/6467

Data Source

The data for this API is taken from WikiData and is imported to a database via the DinosaurTableSeeder, this reads in the raw JSON data from Wikidata which is saved in the project at database/data/wikidata_dinosaurs.json
The SPARQL query for Wikidata is as follows:

    SELECT ?dinosaur ?dinosaurLabel ?taxon ?image ?startTime ?endTime ?gallery ?sizeComparison ?encyclopedia ?article
    WHERE
    {
      ?dinosaur wdt:P31 wd:Q23038290;
                wdt:P18 ?image.
      MINUS {
        ?dinosaur wdt:p171 wdt:Q171283.  
      }
      OPTIONAL { ?dinosaur wdt:P225 ?taxon. }
      OPTIONAL { ?dinosaur wdt:P580 ?startTime. }
      OPTIONAL { ?dinosaur wdt:P582 ?endTime. }
      OPTIONAL { ?dinosaur wdt:P8512 ?sizeComparison. }
      OPTIONAL { ?dinosaur wdt:P1417 ?encyclopedia. }
      OPTIONAL {
          ?article schema:about ?dinosaur .
          ?article schema:inLanguage "en" .
          ?article schema:isPartOf <https://en.wikipedia.org/> .
      }
      ?dinosaur rdfs:label ?dinosaurLabel filter (lang(?dinosaurLabel) = "en") .
    }

dinosaur-api's People

Contributors

georgebetts avatar

Stargazers

Alberto Nieto avatar Gustavo Herrero Nunes avatar James Paul Espeña avatar

Watchers

 avatar

dinosaur-api's Issues

Add dinosaur data to a search engine index

A search engine tool such as Elasticsearch or Meilisearch would be used to search all the dinosaur data.

A search endpoint would need to be added to the REST API, which utilises the search engine to provide rapid results.

Dinosaur data would need to be created in the search engine index. This would typically be done via a scheduled task and via API when a new dinosaur is added, but I think in this projects it's unlikely for new dinosaurs to be added. So probably the best way to approach this is a one time script.

Add hosting and deployment

The API needs to be hosted to be accessible in the browser.

Hosting infrastructure needs to be set up.

A deployment pipeline should be created to deply updates & releases.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.