├── .gitignore
├── .hgignore
├── HACKING.txt
├── LICENSE
├── MANIFEST.in
├── NEWS.txt
├── README-pypi.rst
├── README.md
├── bootstrap.py
├── buildout.cfg
├── setup.py
└── src
└── spacexpython
├── __init__.py
├── capsules.py
├── launches.py
├── rockets.py
└── urldata.py
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 |
3 | .installed.cfg
4 | bin
5 | develop-eggs
6 |
7 | *.egg-info
8 |
9 | tmp
10 | build
11 | dist
12 |
13 | src/spacexpython/test.py
--------------------------------------------------------------------------------
/.hgignore:
--------------------------------------------------------------------------------
1 | syntax: glob
2 |
3 | .installed.cfg
4 | bin
5 | develop-eggs
6 |
7 | *.egg-info
8 |
9 | tmp
10 | build
11 | dist
12 |
--------------------------------------------------------------------------------
/HACKING.txt:
--------------------------------------------------------------------------------
1 | Development setup
2 | =================
3 |
4 | To create a buildout,
5 |
6 | $ python bootstrap.py
7 | $ bin/buildout
8 |
9 | Release HOWTO
10 | =============
11 |
12 | To make a release,
13 |
14 | 1) Update release date/version in NEWS.txt and setup.py
15 | 2) Run 'python setup.py sdist'
16 | 3) Test the generated source distribution in dist/
17 | 4) Upload to PyPI: 'python setup.py sdist register upload'
18 | 5) Increase version in setup.py (for next release)
19 |
20 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Vinay Phadnis
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | include README.rst
2 | include NEWS.txt
3 |
--------------------------------------------------------------------------------
/NEWS.txt:
--------------------------------------------------------------------------------
1 | .. This is your project NEWS file which will contain the release notes.
2 | .. Example: http://www.python.org/download/releases/2.6/NEWS.txt
3 | .. The content of this file, along with README.rst, will appear in your
4 | .. project's PyPI page.
5 |
6 | News
7 | ====
8 |
9 | 0.2a1
10 | -----
11 |
12 | *Release date: UNRELEASED*
13 |
14 | * Example news entry for the in-development version
15 |
16 |
17 | 0.1
18 | ---
19 |
20 | *Release date: 15-Mar-2010*
21 |
22 | * Example news entry for a released version
23 |
24 |
--------------------------------------------------------------------------------
/README-pypi.rst:
--------------------------------------------------------------------------------
1 | Simple and Easy API Wrapper for `r-spacex/SpaceX-API`_!
2 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 |
4 | Documentation
5 | -------------
6 |
7 | This API Wrapper aims to provide a simple and easy way to use the
8 | `SpaceX-API`_ in Python projects. See the `Wiki`_ for full wrapper
9 | documentation.
10 |
11 | Installation
12 | ------------
13 |
14 | To install via ``pip`` use: ``pip install spacexPython``
15 |
16 | Basic Usage
17 | -----------
18 |
19 | The usage of the wrapper is very easy. It does not require any
20 | initialisation. Just import and start coding:
21 |
22 | .. code:: python
23 |
24 | import spacexpython
25 |
26 | rocket_data = spacexpython.rockets.falconHeavy()
27 | print(rocket_data)
28 |
29 | .. _r-spacex/SpaceX-API: https://github.com/r-spacex/SpaceX-API
30 | .. _SpaceX-API: https://github.com/r-spacex/SpaceX-API
31 | .. _Wiki: https://github.com/phadnisvinay30/SpaceX-Python/wiki
32 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SpaceX API wrapper in Python
2 |
3 |
4 | [](https://github.com/phadnisvinay30/SpaceX-Python/releases)
5 | [](https://github.com/phadnisvinay30/SpaceX-Python/issues)
6 | [](https://github.com/phadnisvinay30/SpaceX-Python/stargazers)
7 | [](https://github.com/phadnisvinay30/SpaceX-Python)
8 |
9 | ### Simple and Easy API Wrapper for [r-spacex/SpaceX-API](https://github.com/r-spacex/SpaceX-API)!
10 |
11 |
12 |
13 |
14 |
15 | ## Documentation
16 | This API Wrapper aims to provide a simple and easy way to use the [SpaceX-API](https://github.com/r-spacex/SpaceX-API) in Python projects.
17 |
18 | See the [Wiki](https://github.com/phadnisvinay30/SpaceX-Python/wiki) for full wrapper documentation.
19 |
20 | ## Installation
21 | To install via `pip` use:
22 | `pip install spacexPython`
23 |
24 | ## Basic Usage
25 | The usage of the wrapper is very easy. It does not require any initialisation. Just import and start coding:
26 | ```python
27 | import spacexpython
28 |
29 | rocket_data = spacexpython.rockets.falconHeavy()
30 | print(rocket_data)
31 | ```
32 |
--------------------------------------------------------------------------------
/bootstrap.py:
--------------------------------------------------------------------------------
1 | ##############################################################################
2 | #
3 | # Copyright (c) 2006 Zope Corporation and Contributors.
4 | # All Rights Reserved.
5 | #
6 | # This software is subject to the provisions of the Zope Public License,
7 | # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
8 | # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9 | # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10 | # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11 | # FOR A PARTICULAR PURPOSE.
12 | #
13 | ##############################################################################
14 | """Bootstrap a buildout-based project
15 |
16 | Simply run this script in a directory containing a buildout.cfg.
17 | The script accepts buildout command-line options, so you can
18 | use the -c option to specify an alternate configuration file.
19 |
20 | $Id: bootstrap.py 102545 2009-08-06 14:49:47Z chrisw $
21 | """
22 |
23 | import os, shutil, sys, tempfile, urllib2
24 | from optparse import OptionParser
25 |
26 | tmpeggs = tempfile.mkdtemp()
27 |
28 | is_jython = sys.platform.startswith('java')
29 |
30 | # parsing arguments
31 | parser = OptionParser()
32 | parser.add_option("-v", "--version", dest="version",
33 | help="use a specific zc.buildout version")
34 | parser.add_option("-d", "--distribute",
35 | action="store_true", dest="distribute", default=True,
36 | help="Use Disribute rather than Setuptools.")
37 |
38 | options, args = parser.parse_args()
39 |
40 | if options.version is not None:
41 | VERSION = '==%s' % options.version
42 | else:
43 | VERSION = ''
44 |
45 | USE_DISTRIBUTE = options.distribute
46 | args = args + ['bootstrap']
47 |
48 | to_reload = False
49 | try:
50 | import pkg_resources
51 | if not hasattr(pkg_resources, '_distribute'):
52 | to_reload = True
53 | raise ImportError
54 | except ImportError:
55 | ez = {}
56 | if USE_DISTRIBUTE:
57 | exec urllib2.urlopen('http://python-distribute.org/distribute_setup.py'
58 | ).read() in ez
59 | ez['use_setuptools'](to_dir=tmpeggs, download_delay=0, no_fake=True)
60 | else:
61 | exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
62 | ).read() in ez
63 | ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
64 |
65 | if to_reload:
66 | reload(pkg_resources)
67 | else:
68 | import pkg_resources
69 |
70 | if sys.platform == 'win32':
71 | def quote(c):
72 | if ' ' in c:
73 | return '"%s"' % c # work around spawn lamosity on windows
74 | else:
75 | return c
76 | else:
77 | def quote (c):
78 | return c
79 |
80 | cmd = 'from setuptools.command.easy_install import main; main()'
81 | ws = pkg_resources.working_set
82 |
83 | if USE_DISTRIBUTE:
84 | requirement = 'distribute'
85 | else:
86 | requirement = 'setuptools'
87 |
88 | if is_jython:
89 | import subprocess
90 |
91 | assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd',
92 | quote(tmpeggs), 'zc.buildout' + VERSION],
93 | env=dict(os.environ,
94 | PYTHONPATH=
95 | ws.find(pkg_resources.Requirement.parse(requirement)).location
96 | ),
97 | ).wait() == 0
98 |
99 | else:
100 | assert os.spawnle(
101 | os.P_WAIT, sys.executable, quote (sys.executable),
102 | '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout' + VERSION,
103 | dict(os.environ,
104 | PYTHONPATH=
105 | ws.find(pkg_resources.Requirement.parse(requirement)).location
106 | ),
107 | ) == 0
108 |
109 | ws.add_entry(tmpeggs)
110 | ws.require('zc.buildout' + VERSION)
111 | import zc.buildout.buildout
112 | zc.buildout.buildout.main(args)
113 | shutil.rmtree(tmpeggs)
114 |
--------------------------------------------------------------------------------
/buildout.cfg:
--------------------------------------------------------------------------------
1 | [buildout]
2 | parts = python scripts
3 | develop = .
4 | eggs = spacex-python
5 |
6 | [python]
7 | recipe = zc.recipe.egg
8 | interpreter = python
9 | eggs = ${buildout:eggs}
10 |
11 | [scripts]
12 | recipe = zc.recipe.egg:scripts
13 | eggs = ${buildout:eggs}
14 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | from setuptools import setup, find_packages
2 | import sys, os
3 |
4 | here = os.path.abspath(os.path.dirname(__file__))
5 | README = open(os.path.join(here, 'README-pypi.rst')).read()
6 | NEWS = open(os.path.join(here, 'NEWS.txt')).read()
7 |
8 |
9 | version = '1.0.3'
10 |
11 | install_requires = [
12 | # List your project dependencies here.
13 | # For more details, see:
14 | # http://packages.python.org/distribute/setuptools.html#declaring-dependencies
15 | 'requests'
16 | ]
17 |
18 |
19 | setup(name='spacexPython',
20 | version=version,
21 | description="Simple Python wrapper for the SpaceX API",
22 | long_description=README + '\n\n' + NEWS,
23 | classifiers=[
24 | # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
25 | ],
26 | keywords='wrapper api spacex',
27 | author='Vinay Phadnis',
28 | author_email='phadnisvinay30@gmail.com',
29 | url='https://github.com/phadnisvinay30/SpaceX-Python',
30 | license='MIT',
31 | packages=find_packages('src'),
32 | package_dir = {'': 'src'},include_package_data=True,
33 | zip_safe=False,
34 | install_requires=install_requires,
35 | entry_points={
36 | 'console_scripts':
37 | ['spacex-python=spacexpython']
38 | }
39 | )
40 |
--------------------------------------------------------------------------------
/src/spacexpython/__init__.py:
--------------------------------------------------------------------------------
1 | # Example package with a console entry point
2 |
3 |
4 | import launches
5 | import rockets
6 |
--------------------------------------------------------------------------------
/src/spacexpython/capsules.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import urldata
3 |
4 |
5 | def capsules():
6 | requestUrl = urldata.Domain.main + urldata.Domain.main_capsules
7 | return makeRequest(requestUrl)
8 |
9 | def custom(capsule_id):
10 | requestUrl = urldata.Domain.main + urldata.Domain.main_capsules + "/" + str(capsule_id)
11 | return makeRequest(requestUrl)
12 |
13 |
14 | def makeRequest(requestUrl):
15 | url_response = requests.get(url=str(requestUrl), timeout=1)
16 | response = url_response.json()
17 | return response
18 |
19 |
--------------------------------------------------------------------------------
/src/spacexpython/launches.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import urldata
3 |
4 |
5 |
6 | def launches():
7 | requestUrl = urldata.Domain.main + urldata.Domain.main_launches
8 | return makeRequest(requestUrl)
9 |
10 | def latest():
11 | requestUrl = urldata.Domain.main + urldata.Domain.latest_launches
12 | return makeRequest(requestUrl)
13 |
14 | def next():
15 | requestUrl = urldata.Domain.main + urldata.Domain.next_launches
16 | return makeRequest(requestUrl)
17 |
18 | def upcoming():
19 | requestUrl = urldata.Domain.main + urldata.Domain.upcoming_launches
20 | return makeRequest(requestUrl)
21 |
22 | def makeRequest(requestUrl):
23 | url_response = requests.get(url=str(requestUrl), timeout=1)
24 | response = url_response.json()
25 | return response
26 |
--------------------------------------------------------------------------------
/src/spacexpython/rockets.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import urldata
3 |
4 |
5 | def rockets():
6 | requestUrl = urldata.Domain.main + urldata.Domain.main_rockets
7 | return makeRequest(requestUrl)
8 |
9 | def falcon1():
10 | requestUrl = urldata.Domain.main + urldata.Domain.falcon_1
11 | return makeRequest(requestUrl)
12 |
13 | def falcon9():
14 | requestUrl = urldata.Domain.main + urldata.Domain.falcon_9
15 | return makeRequest(requestUrl)
16 |
17 | def falconHeavy():
18 | requestUrl = urldata.Domain.main + urldata.Domain.falcon_heavy
19 | return makeRequest(requestUrl)
20 |
21 | def bfr():
22 | requestUrl = urldata.Domain.main + urldata.Domain.big_falcon_rocket
23 | return makeRequest(requestUrl)
24 |
25 | def makeRequest(requestUrl):
26 | url_response = requests.get(url=str(requestUrl), timeout=1)
27 | response = url_response.json()
28 | return response
--------------------------------------------------------------------------------
/src/spacexpython/urldata.py:
--------------------------------------------------------------------------------
1 | # Declare URL Variables over here to be used to make requests
2 |
3 |
4 | class Domain:
5 | # general url to make request
6 | main = "https://api.spacexdata.com/v2/"
7 |
8 | # declaration of the endpoints
9 | # launches
10 | main_launches = "launches"
11 | latest_launches = main_launches + "/latest"
12 | next_launches = main_launches + "/next"
13 | upcoming_launches = main_launches + "/upcoming"
14 |
15 | # rockets
16 | main_rockets = "rockets"
17 | falcon_1 = main_rockets + "/falcon1"
18 | falcon_9 = main_rockets + "/falcon9"
19 | falcon_heavy = main_rockets + "/falconheavy"
20 | big_falcon_rocket = main_rockets + "/bfr"
21 |
22 | # capsules
23 | main_capsules = "capsules"
24 |
25 |
--------------------------------------------------------------------------------