Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add GeoDB cities API #148

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,135 @@ The nearest grocery of SFU is Nesters Market. It is 1.234 miles far, and It is e

</details>

#### [GeoDB Cities](./geodb) -- Collect country, region, city information

<details>
<summary> Which cities have names that start with "Van" and have a population larger than 200000?</summary>

```python
from dataprep.connector import connect

# You can get ”token" for geodb at
# https://rapidapi.com/wirefreethought/api/geodb-cities/details
dc = connect('geodb', _auth={'access_token':token})
df = await dc.query('city', namePrefix='Van', minPopulation="200000", limit="10")
df
```

| | id | wiki data id | name | type | country | region | latitude | longitude | population |
| ---- | ------- | ------------ | --------- | ---- | ------- | ---------------- | --------- | ----------- | ---------- |
| 0 | 10841 | Q24639 | Vancouver | CITY | Canada | British Columbia | 49.260833 | -123.113889 | 631486 |
| 1 | 34611 | Q127623 | Vantaa | CITY | Finland | Åland Islands | 60.300000 | 25.033333 | 223027 |
| 2 | 3453047 | Q83061 | Van | CITY | Turkey | Van Province | 38.501944 | 43.416667 | 353419 |

</details>

<details>
<summary>Which countries have names that start with "F" and use Euro as their currency?</summary>

```python
from dataprep.connector import connect

# You can get ”token" for geodb at
# https://rapidapi.com/wirefreethought/api/geodb-cities/details
dc = connect('geodb', _auth={'access_token':token})
df = await dc.query('country', currencyCode='EUR', namePrefix='F', limit='10')
df
```

| | wiki data id | name | code | currency codes |
| ---- | ------------ | ------- | ---- | -------------- |
| 0 | Q33 | Finland | FI | [EUR] |
| 1 | Q142 | France | FR | [EUR] |

</details>

<details>
<summary>What's the detail information of New York CIty?</summary>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be New York City.


```python
from dataprep.connector import connect

# You can get ”token" for geodb at
# https://rapidapi.com/wirefreethought/api/geodb-cities/details
dc = connect('geodb', _auth={'access_token':token})
df = await dc.query('city_detail', cityid='Q60')
df
```

| | id | wiki data id | type | name | country | country code | region | region code | latitude | longitude | population | elevation meters | timezone |
| ---- | ------ | ------------ | ---- | ------------- | ------------------------ | ------------ | -------- | ----------- | -------- | --------- | ---------- | ---------------- | ----------------- |
| 0 | 123214 | Q60 | CITY | New York City | United States of America | US | New York | NY | 40.67 | -73.94 | 8398748 | 10.0 | America__New_York |

</details>

<details>
<summary>Get all regions with name start with "C" in a United States</summary>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if it will be better to use question sentence or not haha.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, I think sometimes directly using get ... is good!


```python
from dataprep.connector import connect

# You can get ”token" for geodb at
# https://rapidapi.com/wirefreethought/api/geodb-cities/details
dc = connect('geodb', _auth={'access_token':token})
df = await dc.query('country_region', countryid='US', namePrefix='C', limit='10')
df
```

| | wiki data id | name | country code | fips code | iso code |
| ---- | ------------ | ----------- | ------------ | --------- | -------- |
| 0 | Q99 | California | US | 06 | CA |
| 1 | Q1261 | Colorado | US | 08 | CO |
| 2 | Q779 | Connecticut | US | 09 | CT |

</details>

<details>
<summary>Get all cities with population larger than 2000000 in New York, US</summary>

```python
from dataprep.connector import connect

# You can get ”token" for geodb at
# https://rapidapi.com/wirefreethought/api/geodb-cities/details
dc = connect('geodb', _auth={'access_token':token})
df = await dc.query('country_region_city', countryid='US', regioncode='NY', minPopulation='2000000',limit='10')
df
```

| | id | wiki data id | name | latitude | longitude | population |
| ---- | ------- | ------------ | ------------- | --------- | ---------- | ---------- |
| 0 | 122111 | Q18419 | Brooklyn | 40.692778 | -73.990278 | 2636735 |
| 1 | 3101789 | Q11980692 | Kings County | 40.634390 | -73.950270 | 2504700 |
| 2 | 123214 | Q60 | New York City | 40.670000 | -73.940000 | 839874 |
| 3 | 123716 | Q18424 | Queens | 40.704167 | -73.917778 | 2339150 |
| 4 | 3100451 | Q5142559 | Queens County | 40.611744 | -74.061505 | 2230722 |

</details>

<details>
<summary>What are the cities within 3 kilometers around New York?</summary>

```python
from dataprep.connector import connect

# You can get ”token" for geodb at
# https://rapidapi.com/wirefreethought/api/geodb-cities/details
dc = connect('geodb', _auth={'access_token':token})
df = await dc.query('city_near_city', cityid='Q60', radius='3', distanceUnit='KM', limit='10')
df[['id', 'wiki data id', 'name', 'type', 'population', 'distance']]
```

| | id | wiki data id | name | type | population | distance |
| ---- | ------ | ------------ | ------------- | ---- | ---------- | -------- |
| 0 | 122855 | Q2354222 | Crown Heights | CITY | 143000 | 0.46 |
| 1 | 122205 | Q991279 | Brownsville | CITY | 55043 | 1.95 |
| 2 | 123982 | Q840381 | Flatbush | CITY | 105804 | 2.56 |

</details>



### Jobs

#### [The Muse](./themuse) -- Collect Job Ads, Company Information
Expand Down
10 changes: 10 additions & 0 deletions api-connectors/geodb/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"tables": [
"city",
"country",
"city_detail",
"country_region",
"country_region_city",
"city_near_city"
]
}
65 changes: 65 additions & 0 deletions api-connectors/geodb/city.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"version": 1,
"request": {
"url": "https://wft-geo-db.p.rapidapi.com/v1/geo/cities",
"method": "GET",
"authorization": {
"type": "Header",
"keyName": "X-RapidAPI-Key"
},
"params": {
"limit": false,
"countryIds": false,
"excludedCountryIds": false,
"minPopulation": false,
"namePrefix": false,
"timeZoneIds": false,
"location": false,
"radius": false,
"distanceUnit": false
}
},
"response": {
"ctype": "application/json",
"tablePath": "$.data[*]",
"schema": {
"id": {
"target": "$.id",
"type": "int"
},
"wiki data id": {
"target": "$.wikiDataId",
"type": "string"
},
"name": {
"target": "$.name",
"type": "string"
},
"type": {
"target": "$.type",
"type": "string"
},
"country": {
"target": "$.country",
"type": "string"
},
"region": {
"target": "$.region",
"type": "string"
},
"latitude": {
"target": "$.latitude",
"type": "float"
},
"longitude": {
"target": "$.longitude",
"type": "float"
},
"population": {
"target": "$.population",
"type": "int"
}
},
"orient": "records"
}
}
76 changes: 76 additions & 0 deletions api-connectors/geodb/city_detail.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"version": 1,
"request": {
"url": "https://wft-geo-db.p.rapidapi.com/v1/geo/cities/{cityid}",
"method": "GET",
"authorization": {
"type": "Header",
"keyName": "X-RapidAPI-Key"
},
"params": {
"cityid": true
}
},
"examples": {
"cityid": "'Q60'"
},
"response": {
"ctype": "application/json",
"tablePath": "$.data[*]",
"schema": {
"id": {
"target": "$.id",
"type": "int"
},
"wiki data id": {
"target": "$.wikiDataId",
"type": "string"
},
"type": {
"target": "$.type",
"type": "string"
},
"name": {
"target": "$.name",
"type": "string"
},
"country": {
"target": "$.country",
"type": "string"
},
"country code": {
"target": "$.countryCode",
"type": "string"
},
"region": {
"target": "$.region",
"type": "string"
},
"region code": {
"target": "$.regionCode",
"type": "string"
},
"latitude": {
"target": "$.latitude",
"type": "float"
},
"longitude": {
"target": "$.longitude",
"type": "float"
},
"population": {
"target": "$.population",
"type": "int"
},
"elevation meters": {
"target": "$.elevationMeters",
"type": "float"
},
"timezone": {
"target": "$.timezone",
"type": "string"
}
},
"orient": "records"
}
}
73 changes: 73 additions & 0 deletions api-connectors/geodb/city_near_city.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"version": 1,
"request": {
"url": "https://wft-geo-db.p.rapidapi.com/v1/geo/cities/{cityid}/nearbyCities",
"method": "GET",
"authorization": {
"type": "Header",
"keyName": "X-RapidAPI-Key"
},
"params": {
"cityid": true,
"radius": true,
"limit": false,
"countryIds": false,
"excludedCountryIds": false,
"minPopulation": false,
"namePrefix": false,
"timeZoneIds": false,
"distanceUnit": false
}
},
"examples": {
"cityid": "'Q60'",
"radius": "'3'"
},
"response": {
"ctype": "application/json",
"tablePath": "$.data[*]",
"schema": {
"id": {
"target": "$.id",
"type": "int"
},
"wiki data id": {
"target": "$.wikiDataId",
"type": "string"
},
"name": {
"target": "$.name",
"type": "string"
},
"type": {
"target": "$.type",
"type": "string"
},
"country": {
"target": "$.country",
"type": "string"
},
"region": {
"target": "$.region",
"type": "string"
},
"latitude": {
"target": "$.latitude",
"type": "float"
},
"longitude": {
"target": "$.longitude",
"type": "float"
},
"population": {
"target": "$.population",
"type": "int"
},
"distance": {
"target": "$.distance",
"type": "float"
}
},
"orient": "records"
}
}
Loading