Professional, language-idiomatic clients for the Open Notify API, providing real-time data about the International Space Station (ISS) and people currently in space.
All clients implement a consistent interface, adapted to each language's conventions.
interface ISSLocation {
message: string;
date_time: DateTime;
location: {
latitude: number;
longitude: number;
};
}
interface PeopleInSpace {
number: number;
message: string;
people: Array<{ name: string; craft: string }>;
}class OpenNotify {
public static getISSLocation(): Promise<ISSLocation>;
public static getPeopleInSpace(): Promise<PeopleInSpace>;
}Note: Naming conventions (camelCase, snake_case, etc.) are adapted to match each language's standards.
Python
iss_location = open_notify.get_ISS_location()
print("ISS location:")
print("latitude:", iss_location.location.latitude)
print("longitude:", iss_location.location.longitude)
people_in_space = open_notify.get_people_in_space()
for people in people_in_space.people:
print(f"craft: {people.craft}, name: {people.name}")Elixir
case OpenNotifyApi.get_iss_location() do
{:ok, iss_location} ->
IO.puts("Current location of International Space Station:")
IO.puts("latitude: #{iss_location.latitude}")
IO.puts("longitude: #{iss_location.longitude}")
iss_location["timestamp"]
|> DateTime.from_unix()
|> case do
{:ok, date_time} -> IO.puts("Date and time: #{date_time}")
end
{:error, error} ->
IO.inspect(error)
end
case OpenNotifyApi.get_people_in_space() do
{:ok, people_in_space} ->
number = people_in_space["number"]
IO.puts("There are #{number} people in space right now.")
people = people_in_space["people"]
IO.puts("List of people in space:")
for person <- people do
name = person["name"]
craft = person["craft"]
IO.puts("name: #{name}, craft: #{craft}")
end
{:error, error} ->
IO.puts(error)
endGo
iss, err := GetISSLocation()
fmt.Println("Current location of ISS:")
fmt.Printf("latitude: %f\n", iss.Location.Latitude)
fmt.Printf("longitude: %f\n", iss.Location.Longitude)
fmt.Println("People in space right now:")
for _, v := range ppl.People {
fmt.Printf("Craft: %s, Name: %s\n", v.Craft, v.Name)
}
fmt.Printf("Number of people in space: %d\n", ppl.Number).NET (C#)
var iss_loc = await OpenNotify.GetISSLocation();
var output =
$"International Space Station's Location:\n"
+ $"DateTime: {iss_loc?.DateTime.ToLocalTime()}\n"
+ $"Latitude: {iss_loc?.Location?.Latitude}\n"
+ $"Longitude: {iss_loc?.Location?.Longitude}\n";
Console.Write(output);
var people_in_space = await OpenNotify.GetPeopleInSpace();
Console.WriteLine($"There are {people_in_space?.Number} people in space right now.");
var people = people_in_space?.People?.Select(p => $"Craft: {p.Craft}, Name: {p.Name}");
Console.WriteLine("People who are in space:");
Console.WriteLine(string.Join("\n", people));JavaScript/TypeScript
const OpenNotify = require("OpenNotify");
const iss_location = await OpenNotify.getISSLocation();
console.log(
"ISS location:\n" +
`latitude: ${iss_location.latitude}\n` +
`longitude: ${iss_location.longitude}`
);
const peopleInSpace = await OpenNotify.getPeopleInSpace();
console.log("There are", peopleInSpace.number, "people in space right now:");
for (const { name, craft } of peopleInSpace.people) {
console.log(name, "in", craft);
}This project is licensed under the MIT License.