# Package

### How to install the library? 

Let's install library. To do this, click on PyCharm - Preferences - Project: pythonprac - Python Interpreter - '+' and type and install 'requests'.

<hr>

#### Reference; Seoul Air OpenAPI
```
import requests # requests 라이브러리 설치 필요

r = requests.get('http://spartacodingclub.shop/sparta_api/seoulair')
rjson = r.json()
```

- do `print(rjson)`

```
import requests # requests 라이브러리 설치 필요

r = requests.get('http://spartacodingclub.shop/sparta_api/seoulair')
rjson = r.json()

print(rjson)
```
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660616061530/af95lehtM.png align="left")

- We need the row data.

```
import requests # requests 라이브러리 설치 필요

r = requests.get('http://spartacodingclub.shop/sparta_api/seoulair')
rjson = r.json()

rows = rjson['RealtimeCityAir']['row']
print(rows)
```

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660616103695/xYh9hFqwk.png align="left")


```
import requests # requests 라이브러리 설치 필요

r = requests.get('http://spartacodingclub.shop/sparta_api/seoulair')
rjson = r.json()

rows = rjson['RealtimeCityAir']['row']

for row in rows:
    print(row)
```
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660616206801/qlk3vsuD3.png align="left")


- let's see `gu_name` and `index`

```
import requests # requests 라이브러리 설치 필요

r = requests.get('http://spartacodingclub.shop/sparta_api/seoulair')
rjson = r.json()

rows = rjson['RealtimeCityAir']['row']

for row in rows:
    gu_name = row['MSRSTE_NM']
    gu_mise = row['IDEX_MVL']
    print(gu_name, gu_mise)
```
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660616305540/eSfbWQbMj.png align="left")


#### how to see data having index less than 60?
; we need to use `if`


```
import requests # requests 라이브러리 설치 필요

r = requests.get('http://spartacodingclub.shop/sparta_api/seoulair')
rjson = r.json()

rows = rjson['RealtimeCityAir']['row']

for row in rows:
    gu_name = row['MSRSTE_NM']
    gu_mise = row['IDEX_MVL']
    if gu_mise < 60:
        print(gu_name)
```

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660616389560/7cY0XTWXB.png align="left")


















