Skip to content

Commit 6bee39e

Browse files
authored
New Python v2 resolve page (#597)
* Updating Data Sources pages * first drafts of entity import * more work on entities * continued work * continued work * allow sample API key * more work * more work on entities * more work * more changes * more changes * split out custom entities into a separate file * start work on Python v2 docs * start of new Python docs * create all pages for directory and more work on landing page * more work * add skeleton files * rename old Python docs * fix mistaken files * fix files again * fix more files * remove template from PR * changed examples to directly print responses * move pagination out of main page and into node page * wording change suggested by Jorge * fixed response formatting object wording, per Jorge * new node page * start work on resolve * more work * More changes * Finish the resolve page and reword REST resolve page * Remove template from push * Incorporate feedback from Christie * fix missing s on method name
1 parent d03490b commit 6bee39e

File tree

3 files changed

+451
-17
lines changed

3 files changed

+451
-17
lines changed

api/python/v2/node.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ More specifically, this API can perform the following tasks:
1919
- Get the values of a property for individual or multiple nodes.
2020
- Get all connected nodes that are linked with individual or multiple nodes.
2121

22+
* TOC
23+
{:toc}
24+
2225
## Request methods
2326

2427
The following are the methods available for this endpoint.
@@ -60,18 +63,20 @@ All request methods return a `NodeResponse` object. It looks like this:
6063

6164
| Name | Type | Description |
6265
| --------- | ------ | ---------------------------------------------------------------------------- |
63-
| data | object | Data of the property label and value information, keyed by the queried nodes. |
66+
| data | object | Data of the property label and value information, keyed by the queried nodes. |
6467
| nextToken | string | A token used to query the [next page of data](#pagination), if `all_pages` is set to `False` in the query. |
6568
{: .doc-table}
6669

6770
### Response property methods
6871

69-
In addition to the [formatting methods](index.md#response-formatting) available for all reponses classes, you can call the following methods on the `NodeResponse` object:
72+
You can call the following methods on the `NodeResponse` object:
7073

7174
| Method | Description |
7275
|--------|-------------|
73-
| nextToken | Extract the `nextToken` value from the response. See [Pagination](#pagination) below for more details |
74-
{: .doc-table}
76+
| to_dict | Converts the dataclass to a Python dictionary. See [Response formatting](index.md#response-formatting) for details. |
77+
| to_json | Serializes the dataclass to a JSON string (using `json.dumps()`). See [Response formatting](index.md#response-formatting) for details. |
78+
| nextToken | Extracts the `nextToken` value from the response. See [Pagination](#pagination) below for more details |
79+
{: .doc-table }
7580

7681
## fetch
7782

@@ -95,6 +100,7 @@ fetch(node_dcids, expression, all_pages, next_token)
95100

96101
### Examples
97102

103+
{: .no_toc}
98104
{: #fetch_ex1}
99105
#### Example 1: Get all incoming property labels for a given node
100106

@@ -128,6 +134,7 @@ Response:
128134
```
129135
{: .example-box-content .scroll}
130136

137+
{: .no_toc}
131138
{: #fetch_ex2 }
132139
#### Example 2: Get one (outgoing) property value for a given node
133140

@@ -164,6 +171,7 @@ Response:
164171
```
165172
{: .example-box-content .scroll}
166173

174+
{: .no_toc}
167175
#### Example 3: Get a list of all statistical variables
168176

169177
This example gets the list of all statistical variables in the knowledge graph, by fetching all nodes that are types of the class `StatisticalVariable` and using the `<-typeOf` symbol to express the incoming relationships. Also, because of the size of the response, it enables [pagination](#pagination) to split up the response data into multiple calls.
@@ -254,6 +262,7 @@ fetch_property_labels(node_dcids, out, all_pages, next_token)
254262

255263
### Examples
256264

265+
{: .no_toc}
257266
#### Example 1: Get all incoming property labels for a given node
258267

259268
Get all incoming arc property labels, i.e. the property labels that are used in attached nodes, of the node with DCID `geoId/06` (California) by setting the `out` parameter to `False`. This is identical to [example 1](#fetch_ex1) of the `fetch` method.
@@ -311,6 +320,7 @@ fetch_property_values(node_dcids, properties, constraints, out, all_pages, next_
311320

312321
### Examples
313322

323+
{: .no_toc}
314324
#### Example 1: Get one (outgoing) property value for a given node
315325

316326
This example gets the `name` property for a given node with DCID `dc/03lw9rhpendw5`. This is identical to [example 2](#fetch_ex2) of the `fetch` method.
@@ -346,6 +356,7 @@ Response:
346356
```
347357
{: .example-box-content .scroll}
348358

359+
{: .no_toc}
349360
#### Example 2: Get multiple (outgoing) property values for multiple nodes
350361

351362
This example gets the `name`, `latitude`, and `longitude` values for nodes `geoId/06085` and `geoId/06087`.
@@ -443,6 +454,7 @@ Response:
443454
```
444455
{: .example-box-content .scroll}
445456

457+
{: .no_toc}
446458
#### Example 3: Get DCIDs of nodes of a specific type, with an incoming relation to a node
447459

448460
In this example, we use a [filter expression](/api/rest/v2/#filters) to specify "all contained places in
@@ -509,8 +521,6 @@ Response:
509521
```
510522
{: .example-box-content .scroll}
511523

512-
513-
514524
## fetch_all_classes
515525

516526
Fetches all nodes that are entity types, that is, have `Class` as their type.
@@ -530,7 +540,10 @@ fetch_all_classes(all_pages, next_token)
530540

531541
{: .doc-table }
532542

533-
### Example 1: Fetch all classes, with pagination
543+
### Examples
544+
545+
{: .no_toc}
546+
#### Example 1: Fetch all classes, with pagination
534547

535548
This example sets `all_pages` to get a [paginated response](#pagination) with a `next_token` value.
536549

0 commit comments

Comments
 (0)