-
Notifications
You must be signed in to change notification settings - Fork 1
/
ImportConfigs.m
52 lines (47 loc) · 1.44 KB
/
ImportConfigs.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
%% Preamble
clc
clear
close all
%% Import parameters
API="ll"; % ll or lldev
APIver="2.2.0";
APIkey=fileread('APIkey.txt');
options = weboptions;
options.Timeout=20;
options.HeaderFields=['Authorization',strcat("Token ",APIkey)];
%% Import Orbits
FirstCall=webread(strcat("https://",API,".thespacedevs.com/",APIver,"/config/orbit/?limit=100&mode=detailed"),options);
NbOrbits=FirstCall.count;
NbCalls=ceil(NbOrbits/100);
Orbits=FirstCall.results;
nextURL=FirstCall.next;
ii=1;
disp(strcat("Total Orbits :",num2str(NbOrbits)))
while ~isempty(nextURL)
ii=ii+1;
LoopCall=webread(nextURL,options);
Orbits = [Orbits;LoopCall.results];
nextURL=LoopCall.next;
disp(strcat("API Call ",num2str(ii),"/",num2str(NbCalls)))
end
%% Export Orbits Struct
save("data/Orbits.mat","Orbits")
disp("Successfully exported Orbits to file.")
%% Import Statuses
FirstCall=webread(strcat("https://",API,".thespacedevs.com/",APIver,"/config/launchstatus/?limit=100&mode=detailed"),options);
NbStatuses=FirstCall.count;
NbCalls=ceil(NbOrbits/100);
Statuses=FirstCall.results;
nextURL=FirstCall.next;
ii=1;
disp(strcat("Total Statuses :",num2str(NbStatuses)))
while ~isempty(nextURL)
ii=ii+1;
LoopCall=webread(nextURL,options);
Statuses = [Statuses;LoopCall.results];
nextURL=LoopCall.next;
disp(strcat("API Call ",num2str(ii),"/",num2str(NbCalls)))
end
%% Export Statuses Struct
save("Statuses.mat","Statuses")
disp("Successfully exported Statuses to file.")