Metadata-Version: 2.1
Name: airtable_scraper
Version: 0.0.3
Summary: Public airtable web scraper tool
Author-email: Kang Chen <kangchen.work@gmail.com>
License: MIT License
        
        Copyright (c) 2024 Kang Chen
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
        EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
        MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
        IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
        DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
        OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
        OR OTHER DEALINGS IN THE SOFTWARE.
Project-URL: Homepage, https://github.com/kchenTTP/airtable-scraper
Project-URL: Issues, https://github.com/kchenTTP/airtable-scraper/issues
Keywords: airtable,scraper,scraping,web scraper
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas
Requires-Dist: pydantic
Requires-Dist: pytz
Requires-Dist: requests

# Airtable Scraper
<!-- [![Open In Colab](img-link)](colab-link) -->
<!-- [![PyPI](img-link)](pypi-link) -->

A package used to scrape any public airtable.


**Table of Contents**
- [Install](#install)
- [Usage](#usage)
  - [Table Data](#table-data)
  - [Save Airtable As ...](#save-airtable-as-)
  - [Metadata](#metadata)


## Install

```bash
pip install airtable_scraper
```

## Usage

After install, you can use this code for testing (replace url with your own airtable shared view url).

```python
from airtable_scraper import AirtableScraper

url = "https://airtable.com/app7rljHYfQ4tfGrq/shrJ2psoFssctoP5o"
table = AirtableScraper(url=url)

# check status code (ex. 200 = success)
print(table.status)
```

### Table Data

```python
print(table.data)
```

### Save Airtable As ...

#### CSV

- **String**: If no filepath is provided, returns a csv formatted string.

```python
csv_str = table.to_csv()
```

- **CSV File**: If a filepath is provide, save as a csv file. (Change "my_table.csv" to your own filename)

```python
table.to_csv("my_table.csv")
```

#### JSON

- **String**: If no filepath is provided, returns a json formatted string.

```python
json_str = table.to_json()
```
- **JSON File**: If a filepath is provide, save as a json file. (Change "my_table.json" to your own filename)

```python
table.to_json("my_table.json")
```

#### Python Dictionary

Converts data into python dictionary format.

- **`orient`**: Use `orient` parameter to change the type of values of the dictionary.
  - "records": list like [{column -> value}, … , {column -> value}]
  - "index": dict like {index -> {column -> value}}

```python
data_d = table.to_dict()
```

#### Pandas DataFrame

Save data to Pandas DataFrame.

```python
df = table.to_dataframe()
```


### Metadata

You can use these helper methods to checkout additional Airtable metadata or http request parameters.

#### Airtable Information

print a summary of the airtable, including the airtable column type and python datatype.

```python
table.info()
```

*Additional Airtable shared view information*

```python
print(table.view_id)
print(table.table_id)
print(table.app_id)
print(table.share_id)
```

#### HTTP Request Parameters & Responses

```python
print(table.headers)
print(table.request_id)
print(table.raw_rows_json)
print(table.raw_columns_json)
```
