This is a ready-to-use and async-enabled API wrapper made in Python, for Python, for the Star Citizen API made by Corentin Urbain. It features full support for dot notation and autocomplete data as well as custom data classes for ease of use.
An API wrapper can help streamline the process of accessing an API for a particular language, in this one's case, Python. The API it is accessing provides raw JSON data (depending on the queried URL) of information scraped from the official RSI website.
Here is what it looks like raw:
{"data":{"affiliation":[],"organization":{"image":"https://robertsspaceindustries.com/media/uh2fvrq9575zvr/heap_infobox/INVFED-Logo.png","name":"Invictus Intergalactic Federation","rank":"Enlisted Member","sid":"INVFED","stars":1},"profile":{"badge":"Grand Admiral","badge_image":"https://media.robertsspaceindustries.com/a6kpgl3byjake/heap_thumb.png","bio":"Flippers on the HOSAS. Check out my main org INVFED!\n\nDiscord: Turtle-12#0001\n\nOrg Website: https://www.invfed.com/home\nOrg RSI Page: https://robertsspaceindustries.com/orgs/INVFED\nOrg Twitter: https://twitter.com/Official_INVFED","display":"Turtle-12","enlisted":"2021-07-30T00:00:00.000000","fluency":["English"],"handle":"Turtle-12","id":"n/a","image":"https://robertsspaceindustries.com/media/xm8k6mibbrgnqr/heap_infobox/Invfed_turtle.png","location":{"country":"United States","region":"California"},"page":{"title":"Turtle-12 | Turtle-12 - Invictus Intergalactic Federation | INVFED (Enlisted Member) - Roberts Space Industries | Follow the development of Star Citizen and Squadron 42","url":"https://robertsspaceindustries.com/citizens/Turtle-12"},"website":"https://twitter.com/invfed_turtle"}},"message":"Not Modified","source":"live","success":1}Frankly, not very readable, maybe that's just me. The wrapper takes that raw stream and converts it into accessible and understandable formats for consumption and use. Instead of scanning the clump of letters for info, you can simply use the User object the wrapper makes to access info. Example: user.data.profile.page.url would now display the user's RSI page URL instead: https://robertsspaceindustries.com/citizens/Turtle-12. Dot notation or direct dictionary manipulation are acceptable forms of data access.
Anything you want to get information from the RSI site for. Ship data? Sure. User's profile picture? Yes sir. Full organization's member list? Of course. As soon as it is updated on the RSI site, it will be updated fo your application, as each parse is done to the live site. (Caching options are coming soon.)
- Step one is getting your API key here.
- Place it into a
.envfile in the main directory containing one line:
export STARCITIZEN_API_KEY = "YOUR KEY HERE"- Now use dotenv package to import the key into your main.py:
import os
from dotenv import load_dotenv
load_dotenv()
api_key = os.getenv("STARCITIZEN_API_KEY")- Start a client object by feeding your key into the
RSI.Clientclass:
Client = RSI.Client(api_key)- You can now use any of the API methods by using dot notation:
user = Client.get_user("Turtle-12") # returns User object of Turtle-12 user page
RSI_page_link = user.data.profile.page.url # an example of accessing the data using dot notationWill return User object of the queried user
- user:
User- data:
User_Data- affiliation:
listof the user's affiliation orgs - organization
User_Organization- image:
strreturns profile page org image url - name:
strreturns full org name - rank:
strreturns the user's rank in the org - sid:
strreturns the shorthand ID of the org - star:
intreturns how many "star" icons the user gets due to their org rank
- image:
- profile:
User_Profile- badge:
strreturns title of displayed badge - badge_image:
strurl of badge image - bio:
strreturns entire shorthand bio - display:
strreturns the user's RSI display name - enlisted:
strreturns str format of the date the user enlisted their RSI account - fluency:
strreturns str list of fluent languages - handle:
strreturns user's RSI handle name - id:
strreturns user account ID if applicable - image:
strurl of user's profile picture - location:
Location- country:
strreturns user's country - region:
strreturns user's region
- country:
- page:
Page- title:
strreturn full HTML page title - url:
strreturn user's RSI account page url
- title:
- website:
strurl of user's listed website
- badge:
- affiliation:
- message:
strreturns message health - source:
strreturns the source's version (should always be 'live') - success:
intreturns binary boolean of query success (1=True & 0=False)
- data:
# query example
user = Client.get_user("Turtle-12")
# example test proof
print("----------Testing----------")
if user.success == 1:
bool_succ = "Success"
elif user.success != 1:
bool_succ = "Failure"
print("Success: " + bool_succ + " from " + user.source)
print("User's RSI Handle: " + user.data.profile.display)
print("User's Organization: " + user.data.organization.name)
print("User's RSI Page URL: " + user.data.profile.page.url)
print("---------------------------")This will return the following:
----------Testing----------
Success: Success from live
User's RSI Handle: Turtle-12
User's Organization: Invictus Intergalactic Federation
User's RSI Page URL: https://robertsspaceindustries.com/citizens/Turtle-12
---------------------------Will return Organization object of the queried organization shorthand ID
This a fan-made and community-based project. Tucker Komasa, the Star Citizen API, and the SC API Wrapper, have no affiliation with the Cloud Imperium group of companies. This project is made by the community, maintined by the community, and made for the community.
This is an unofficial Star Citizen fansite, not affiliated with the Cloud Imperium group of companies. All content on this site not authored by its host or users are property of their respective owners. All game content and materials are copyright of Cloud Imperium Rights LLC and Cloud Imperium Rights Ltd.. Star Citizen®, Squadron 42®, Roberts Space Industries®, and Cloud Imperium® are registered trademarks of Cloud Imperium Rights LLC. All rights reserved.
By using this project, you agree to the terms and conditions of the Star Citizen API. The project is a tool based around the Star Citizen API, any development, opinions, achievements, issues, etc. centered around the Star Citizen API are its own.
