DroneDeploy
Search…
Fetching all Plans for your Organization

Fetching all Plans for your Organization

Below is the query to fetch all the plans, with their name, geometry, location and the date they were created. Since this is a paged API you also need to fetch the pageInfo, see Pagination for more details.
1
query GetPlans{
2
viewer{
3
organization{
4
plans(first:50){
5
pageInfo{
6
hasNextPage
7
endCursor
8
}
9
edges{
10
cursor
11
node{
12
name
13
geometry{
14
lat
15
lng
16
}
17
location {
18
lat
19
lng
20
}
21
dateCreation
22
}
23
}
24
}
25
}
26
}
27
}
Copied!
You can try this query out yourself using the API explorer here.
The top level query viewer is the context for the currently logged in user. From this you fetch the organization object and the first 50 of the plans associated with that. If you have less than 50 plans you are done. If you have more example you will get a response like this.
1
{
2
"data": {
3
"viewer": {
4
"organization": {
5
"plans": {
6
"pageInfo": {
7
"hasNextPage": true,
8
"endCursor": "YXJyYXljb25uZWN0aW9uOjI="
9
},
10
"edges": [
11
... // Data removed for the sake of brevity
12
]
13
}
14
}
15
}
16
}
17
}
Copied!
As you can see in the pageInfo section hasNextPage is True so you know you need to fetch the next page of data. To do this simply modify your query to set the after paging parameter to the endCursor from the pageInfo:
1
query GetPlans{
2
viewer{
3
organization{
4
plans(first:50, after:"YXJyYXljb25uZWN0aW9uOjI="){
5
pageInfo{
6
hasNextPage
7
endCursor
8
}
9
edges{
10
cursor
11
node{
12
name
13
geometry{
14
lat
15
lng
16
}
17
location {
18
lat
19
lng
20
}
21
dateCreation
22
}
23
}
24
}
25
}
26
}
27
}
Copied!

More Detail

If you look through the schema the plans query returns type Plan. This is an interface for the common fields across all types of plans. There are more specific types of Plans, specifically MapPlan which includes more data such as exports. To fetch these extra fields you need to use an Inline Fragment.
1
query GetPlans{
2
viewer{
3
organization{
4
plans(first:50){
5
edges{
6
node{
7
id
8
name
9
... on MapPlan{
10
status
11
}
12
}
13
}
14
pageInfo{
15
hasNextPage
16
endCursor
17
}
18
}
19
}
20
}
21
}
Copied!
This specifies that you are looking for the id and name of all plans, but for objects of type MapPlan you want the status of the processing as well.