Giter Site home page Giter Site logo

phalt / swapi Goto Github PK

View Code? Open in Web Editor NEW
896.0 28.0 502.0 205 KB

*NOT MAINTAINED - NO GUARENTEE TO BE UP*

Home Page: https://phalt.github.io/pokeapi-and-swapi-going-forward/

License: BSD 3-Clause "New" or "Revised" License

Makefile 1.79% Python 72.46% CSS 0.29% HTML 25.45%
star-wars-api api python beginner-friendly

swapi's Introduction

SWAPI

The Star Wars API

NO LONGER MAINTAINED!

If you rely on this project for your own tools - then please fork and spin up your own instance. It's a pretty simple project, and the Makefile will take you a long way.

If you are looking for an API to play with to learn about APIs, then I recommend https://pokeapi.co.

swapi's People

Contributors

antoine-richard avatar astagi avatar bfontaine avatar christianliebel avatar clementallen avatar coderanger avatar darul75 avatar evelinag avatar giammaleoni avatar gianpaj avatar glaforge avatar igordcsouza avatar johnrees avatar jp26jp avatar jstoiko avatar kylesurowiec avatar m-yankov avatar maartendekker1998 avatar markfchavez avatar mihazelnik avatar nickescallon avatar phalt avatar philnash avatar timwco avatar videocard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swapi's Issues

Inconsistent Data

A few character's species and homeworlds are listed as an empty array, whereas it would be more beneficial to be listed as 'unknown'.

people/82, people/2, and people/75: species and homeworlds are empty arrays

starships/3/ - length includes a comma, whereas all other number data doesn't include commas
starships/11/ - speed includes km unit and should just be a number

Person: key species: String instead of [String]

Hi @phalt . Awesome job with this API, but I don't understand your choice for species' key in the person type. Why is it an array of String??
I've checked all the person records, and all the records have just one specie.
And it's quite normale, I mean a person should have just one specie, how is it possibile to belong to two species?

So the specie's key shouldn't be just a single String like for planets?

I'm telling you because to fetch the species' name for the people it costs one more function than the planets name fetching.

Regards, Andrea Miotto

"Try it now!" section breaks without trailing slash

On the swapi.co site, the "Try it now!" section breaks if there is not a trailing slash on the request.

Examples

Works: people/1/
Doesn't Work: people/1

Investigation

Requests that do not have the trailing slash are immediately cancelled and redirected (by the browser?) to an HTTP endpoint that does have the trailing slash.

image

This HTTP request fails with the following error in the console:

Mixed Content: The page at 'https://swapi.co/' was loaded over HTTPS, but requested an insecure
XMLHttpRequest endpoint 'http://swapi.co/api/people/1/'. This request has been blocked; the
content must be served over HTTPS.

I see that you use CloudFlare, so maybe there is some configuration that controls this? I'm not sure where to start investigating an error like this.

Browser: Google Chrome Version 57.0.2987.110

schema queries not working?

I have tried various schema queries such as:

http://swapi.co/api/films/schema/

and get a 404. Am I doing something wrong?

Species Schema Broken

I pulled the Species schema and had a devil of a time with it. it looks like the list of required fields got corrupted. Here is is the schema fixed based on the actual data ...

species.schema.fixed.json

Thanks,

Nick

Add images

I suggest adding images to the data for each entity, that would be much more better in creating full-featured apps based on the API

ETag support

I'd love to be able to cache on the client, but currently have no way of determining when the cache is stale. ETags to the rescue?

Linked image resources

A profile image, or an images section (filled with links to images) that comes with each resource would be a nice addition. It would afford one to make a visual browser on top of SWAPI.

Add name in array of linked resource URLS

For example:

"starships": [{"name": "X-wing", "url": "http://swapi.co/api/starships/12/"}]

This would allow someone to build a url without having to query for each value in the array in order to get the name.

Get random thing (suggestion)

Hi folks, is it possible to get something like swapi.com/api/vehicles/random?

I'm making this app that gets a random thing by putting a random number in the url. (from 1 to the "count" of entries specified in the description of each endpoint) But sometimes I get a 404 errors.

For instance, there are 37 total vehicles, when I get a number in between, let's say 13, I get a 404 http://swapi.co/api/vehicles/13/

I would love to contribute but I only know Javascript :/

Add GraphQL support

GraphQL already has a repository with a schema and server wrapper around SWAPI here. It would be nice to have that as part of the core project and docs as well.

Affiliations

I would be happy to work on faction details for People, eg Resistance, Rebels, Republic, Empire, First Order, etc.

Species class inconsistencies

There are 17 species of class "mammal", and 1 species, Twi'lek, of class "mammals". Did you mean "mammal"?

There are 3 species of class "reptile", and 1 species, Clawdite, of class "reptilian". Did you mean "reptile"?

Thanks,

Bill

@LogicalFellaC

Unknown Planet URL

For some reason planet/28 is 'Unknown' and has empty data. Several characters are linked to this URL. Perhaps it would be better to link characters with an unknown homeworld to an empty array?

Getting UnicodeDecodeError at /api/people/66/

Requesting http://swapi.co/api/people/66/?format=wookiee causes a UnicodeDecodeError. This works fine when not requesting the wookiee format. Looks like it's caused by an accented character in some of the character names like Dormé. The error occurs here:

/Users/mdhora/Github/swapi/resources/renderers.py in render
return bytes(self.translate_to_wookie(encoded_data)) ...

/Users/mdhora/Github/swapi/resources/renderers.py in translate_to_wookie
translated_data += char

data dump is behind the hosted API

Looks like a 'make dump_data' is needed as the latest data from the hosted API is not in the fixtures/*.json files.

Is there anyway I can get this data myself ?

Spelling mistake for character name

Hi, I was using your API and also the official one to extract out a list of names and found that Ratts Tyerel should be Ratts Tyerell. Looking around it doesn't seem like the actual database is part of this repo so I'm not sure how to make a PR for this.

The URI is: http://swapi.co/api/people/47/

Meta property on resources

I propose taking the properties of a resource that are actually properties of the system that stores the resource and moving them into a property called "meta".

i.e. If some resource is:

{
      "name": "Luke Skywalker",
      "height": "1.72 m",
      "mass": "77 Kg",
      "hair_color": "Blond",
      "skin_color": "Caucasian",
      "eye_color": "Blue",
      "birth_year": "19 BBY",
      "gender": "Male",
      "homeworld": "http://swapi.co/api/planets/1/",
      "films": [
          "http://swapi.co/api/films/1/",
          "http://swapi.co/api/films/2/",
          "http://swapi.co/api/films/3/"
      ],
      "species": [
          "http://swapi.co/api/species/1/"
      ],
      "vehicles": [
          "http://swapi.co/api/vehicles/14/",
          "http://swapi.co/api/vehicles/30/"
      ],
      "starships": [
          "http://swapi.co/api/starships/12/",
          "http://swapi.co/api/starships/22/"
      ],
      "created": "2014-12-09T13:50:51.644000Z",
      "edited": "2014-12-10T13:52:43.172000Z",
      "url": "http://swapi.co/api/people/1/"
}

Then the resource would be:

{
      "name": "Luke Skywalker",
      "height": "1.72 m",
      "mass": "77 Kg",
      "hair_color": "Blond",
      "skin_color": "Caucasian",
      "eye_color": "Blue",
      "birth_year": "19 BBY",
      "gender": "Male",
      "homeworld": "http://swapi.co/api/planets/1/",
      "films": [
          "http://swapi.co/api/films/1/",
          "http://swapi.co/api/films/2/",
          "http://swapi.co/api/films/3/"
      ],
      "species": [
          "http://swapi.co/api/species/1/"
      ],
      "vehicles": [
          "http://swapi.co/api/vehicles/14/",
          "http://swapi.co/api/vehicles/30/"
      ],
      "starships": [
          "http://swapi.co/api/starships/12/",
          "http://swapi.co/api/starships/22/"
      ],
      "meta": {
            "created": "2014-12-09T13:50:51.644000Z",
            "edited": "2014-12-10T13:52:43.172000Z",
            "url": "http://swapi.co/api/people/1/"
      }
}

The change being that the last three properties don't actually describe the resource but in fact describe the storage system. "created" is not Luke's birth year, and "edited" makes little sense.

I've taken to using a schema like this for APIs I've implemented as it is a great place to put other extended information that describes the system being used to store the resource. i.e. creation and edited dates, who created and edited, permissions that you (the callee) have on this resource, metrics about the system and not the resource itself (i.e. how many times has this resource been requested, rather than how tall is this person), and so on.

This change is really to help the API grow in functionality in the future and to help the schema communicate more clearly which parts of the resource schema describe the resource.

?format=wookiee does not work

Hi @astagi, the url formatting does not properly work.

I tried it out and I get 404 errors. Can you please write a test that mimics the tests we have for urls, but with your rendering? That should help you understand what the bug is, and then fix it.

I've rolled back to a previous version for now.

CORS allow headers

Would you consider adding CORS headers similar to below so the API (read-only) could be accessed directly from browser code?

Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With
Access-Control-Allow-Methods: GET

I would like to use this API while teaching some front end coding courses and would like my students to be able to just fire up a new tab in their browser and start making requests via fetch.

Brief Character Descriptions

It would be nice if each character had a sentence or two description. It would really tie the data together nicely. Knowing their physical characteristics just doesn't seem enough in this case. I am only proposing this for the characters.

Example:

name: 'Anakin Skywalker',
bio: 'Anakin Skywalker was a Force-sensitive human male who served the Galactic Republic as a Jedi Knight, and later the Galactic Empire as the Sith Lord Darth Vader.'

(Bio was one-liner from wookiepedia)

Chapter / Scene Breakdown

Add a chapter-level breakdown for each scene in each movie, to map character / species / vehicle / etc etc co-occurence.

Requires a new resource and some data collection.

Include id for a given resource in list view

For example, when querying /people, the individual records don't have an id property, but this would be terribly useful and be in line with common RESTful api practice. It would be more useful for using SWAPI as a fake backend to test some front end functionality than simply relying on the url field.

Canon / Films data only?

Hi,
I was wondering if you'd accept pull requests for non-canon data, i.e. starships etc from the expanded universe, like in the EGVV book? Or is the intention to specifically be films-only?

Where's Yoda?

"Persons" page does not include information about Yoda. He's not a person, but he's important!

Inconsistent format of data for gravity field for planets

A handful of the planets include the string standard in the value for the gravity field while the remainder use a numeric value, (excluding the unknown values). I've included a table below listing the planets and their gravity values. Is this intentional? Looking at the documentation, there's no mention of any other unit of measurement besides standard gravity. I'd like to propose the values be updated to remove the unit of measurement, (would help with #15).

Additionally, a defined format for the data presented by the gravity field would be beneficial when parsing considering the existing variation in values, (looking specifically at Bespin). I'd like to propose the following ...

number
number (discriminator)
number1 (discriminator1), number2 (discriminator2), numberN (discriminatorN)

  • number is the standard gravity.
  • discriminator is an optional, character restricted string surrounded by parenthesis used to add context to the value, (refer to row for Bespin in table below).

Thoughts?

id name gravity
1 Tatooine 1 standard
2 Alderaan 1 standard
3 Yavin IV 1 standard
4 Hoth 1.1 standard
5 Dagobah N/A
6 Bespin 1.5 (surface), 1 standard (Cloud City)
7 Endor 0.85 standard
8 Naboo 1 standard
9 Coruscant 1 standard
10 Kamino 1 standard
11 Geonosis 0.9 standard
12 Utapau 1 standard
13 Mustafar 1 standard
14 Kashyyyk 1 standard
15 Polis Massa 0.56 standard
16 Mygeeto 1 standard
17 Felucia 0.75 standard
18 Cato Neimoidia 1 standard
19 Saleucami unknown
20 Stewjon 1 standard
21 Eriadu 1 standard
22 Corellia 1 standard
23 Rodia 1 standard
24 Nal Hutta 1 standard
25 Dantooine 1 standard
26 Bestine IV unknown
27 Ord Mantell 1 standard
28 unknown (#40) unknown
29 Trandosha 0.62 standard
30 Socorro 1 standard
31 Mon Cala 1
32 Chandrila 1
33 Sullust 1
34 Toydaria 1
35 Malastare 1.56
36 Dathomir 0.9
37 Ryloth 1
38 Aleen Minor unknown
39 Vulpter 1
40 Troiken unknown
41 Tund unknown
42 Haruun Kal 0.98
43 Cerea 1
44 Glee Anselm 1
45 Iridonia unknown
46 Tholoth unknown
47 Iktotch 1
48 Quermia unknown
49 Dorin 1
50 Champala 1
51 Mirial unknown
52 Serenno unknown
53 Concord Dawn unknown
54 Zolan unknown
55 Ojom unknown
56 Skako 1
57 Muunilinst 1
58 Shili 1
59 Kalee 1
60 Umbara unknown

Search for Resources via name

In Pokeapi, we can search for Pokémon via name:

HTTP GET /api/v1/pokemon/mew

It would be amazing to have this feature in SWAPI.

HTTP GET /api/people/Yoda

Adding release date to films data

Hi!

First of all, thanks for this amazing API!

I am wondering if you have planed to add the release date of film into the data.

E.g. for Episode IV - A New Hope --> 25 May 1977 (USA)

If you think is an interesting feature, maybe I can help implementing

Best regards.

Feature request: Return all IDs as v4 UUID

UUIDs have the benefits of being globally unique, which means that if someone brings in data from an API that returns a UUID, they can use that UUID as the internal ID as well.

If IDs are returned sequentially, the API caller have to create a different ID internally and then map it to the external ID for later updates.

(Also, for those that like an orderly database, internal UUIDs avoid the problem of leaving gaps in a sequence if removing/reordering things)

Permission to serve swapi content from GraphCMS

Hey there,

I am one of the makers of GraphCMS. We are currently in beta and we are looking for some cool demo content that we would love to serve from GraphCMS as public GraphQL APIs for showcasing reasons.

We would like to create a port of the content and give anyone who wants to contribute to the content a free contributor account. We would also like to offer the project as a GraphCMS content model template, so users could easily clone the project and play around with it.

Of course we will give proper credit to the makers.

Does that work?

Anyone interested in contributing?

Best regards,

Michael Lukaszczyk

if I translate will you add it?

Hi @phalt , if I'm going to translate the resources json files into italian, will you add them? with a new query string that allows to select the language?

Return name in addition to URL array

Hi is it possible to return the resource name of the array elements in addition to the url like when calling:
http://swapi.co/api/films/1/
we get an array of planets, species, starships, vehichles and characters. It would be great if we could receive not only an array of URL like:
["http://swapi.co/api/planets/8/", "http://swapi.co/api/planets/9/", "http://swapi.co/api/planets/1/"]

but also the names of the planets like:
["Naboo", "Coruscant", "Tatooine"]

Schema types standardization

Why always use Strings for all types, where some properties would make more sense if they were integers or doubles (especially people.mass & people.height could be doubles, and even people.birth_year could be a signed integer (which could be null if unknown).

That would make the parsing much more easier, instead of having to parse each string client-side.

Count on homepage is wrong

The count on the homepage is wrong and only tracks "detail" (individual) hits, we have over twice as many "list" (group) hits. Change the count so it is an sum of both detail + list.

The code should look something like this:

detail_count = keen.count('detail_hit')
list_count = keen.count('list_hit')
schema_count = keen.count('schema_hit')
hits = detail_count + list_count + schema_count

and the changes should be made here

Change URL protocol in response data based on whether the request was made over HTTPS

Hi!

First, I would like to say that I love this project and I use to teach my students about APIs. It's awesome!

Second, I have a small feature request. Could we detect on the server whether the user-agent made the request over HTTPS and update any URLs in the response data to use HTTPS as their protocol?

Currently, running curl https://swapi.co/api/films/ results in

{
    "count": 7,
    "next": null,
    "previous": null,
    "results": [{
        "title": "A New Hope",
        ...
        "species": ["http://swapi.co/api/species/3/", "http://swapi.co/api/species/2/", "http://swapi.co/api/species/1/"],
        "created": "2015-04-17T06:51:30.504780Z",
        "edited": "2015-12-17T14:31:47.617768Z",
        "url": "http://swapi.co/api/films/7/"
    }]
}

I am proposing a desired output of

{
    "count": 7,
    "next": null,
    "previous": null,
    "results": [{
        "title": "A New Hope",
        ...
        "species": ["https://swapi.co/api/species/3/", "https://swapi.co/api/species/2/", "https://swapi.co/api/species/1/"],
        "created": "2015-04-17T06:51:30.504780Z",
        "edited": "2015-12-17T14:31:47.617768Z",
        "url": "https://swapi.co/api/films/7/"
    }]
}

Translations

Hi,
Would you be interested in providing the data in different languages? My motivation for this is for my kids. It would be a cool project to write some application around the swapi but they don't speak English and showing the data in French would be much more interresting.
I can help and provide the necessary translations.
Regards,
Bernard.

Switch to HTTPS

As part of a general commitment to keeping people's personal details safe on the web (yes, even for Star Wars geeks!) it would be great if the site could be served over HTTPS.

I can recommend CloudFlare's free SSL plan - also has the advantage of giving you a nice CDN.

Schema Changes Suggestions

Context:

  "films": [
      "http://swapi.co/api/films/1/",
      "http://swapi.co/api/films/2/",
      "http://swapi.co/api/films/3/"
  ],

Relevant section of the schema:
https://github.com/phalt/swapi/blob/master/resources/schemas/people.json#L43

While listing out the films is a starting point, using HAL - http://stateless.co/hal_specification.html - would make this much more powerful. Check out the heading "Representing Multiple Links With The Same Relation" because structuring the JSON like this would allow more flexibility in displaying data without causing the client to make more requests.

_items: {
    "films": [{
            "name": "A New Hope",
            "href": "/films/1/"
    },{
            "name": "The Empire Strikes Back",
            "href": "/films/2/"
    }]
}

I'd also apply this to the species, vehicles, planets subresources but I wanted to give a single example.

Fix for people with missing species

The following people have a missing species. Here are their proper species.

The following are Human (species/1/):
Ric Olié (people/39/)
Quarsh Panaka (people/42/)
Captain Phasma (people/88/)

The following is a Droid (species/2/):
R4-P17 (people/75/)

Thanks for your fine work,

Bill

@LogicalFellaC

The Force Awakens Data

The current Force Awakens data is fairly limited. Now that the film has been out for a while, perhaps more information is now available.

Also no Kylo Ren!

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.