How to load data from New York Times to TiDB
Learn how to use Airbyte to synchronize your New York Times data into TiDB within minutes.


Building your pipeline or Using Airbyte
Airbyte is the only open source solution empowering data teams to meet all their growing custom business demands in the new AI era.
Building in-house pipelines
- Inconsistent and inaccurate data
- Laborious and expensive
- Brittle and inflexible
After Airbyte
- Reliable and accurate
- Extensible and scalable for all your needs
- Deployed and governed your way
Start syncing with Airbyte in 3 easy steps within 10 minutes



Take a virtual tour
Demo video of Airbyte Cloud
Demo video of AI Connector Builder
Setup Complexities simplified!
Simple & Easy to use Interface
Airbyte is built to get out of your way. Our clean, modern interface walks you through setup, so you can go from zero to sync in minutes—without deep technical expertise.
Guided Tour: Assisting you in building connections
Whether you’re setting up your first connection or managing complex syncs, Airbyte’s UI and documentation help you move with confidence. No guesswork. Just clarity.
Airbyte AI Assistant that will act as your sidekick in building your data pipelines in Minutes
Airbyte’s built-in assistant helps you choose sources, set destinations, and configure syncs quickly. It’s like having a data engineer on call—without the overhead.
What sets Airbyte Apart
Modern GenAI Workflows
Streamline AI workflows with Airbyte: load unstructured data into vector stores like Pinecone, Weaviate, and Milvus. Supports RAG transformations with LangChain chunking and embeddings from OpenAI, Cohere, etc., all in one operation.
Move Large Volumes, Fast
Quickly get up and running with a 5-minute setup that enables both incremental and full refreshes for databases of any size, seamlessly scaling to handle large data volumes. Our optimized architecture overcomes performance bottlenecks, ensuring efficient data synchronization even as your datasets grow from gigabytes to petabytes.
An Extensible Open-Source Standard
More than 1,000 developers contribute to Airbyte’s connectors, different interfaces (UI, API, Terraform Provider, Python Library), and integrations with the rest of the stack. Airbyte’s AI Connector Builder lets you edit or add new connectors in minutes.
Full Control & Security
Airbyte secures your data with cloud-hosted, self-hosted or hybrid deployment options. Single Sign-On (SSO) and Role-Based Access Control (RBAC) ensure only authorized users have access with the right permissions. Airbyte acts as a HIPAA conduit and supports compliance with CCPA, GDPR, and SOC2.
Fully Featured & Integrated
Airbyte automates schema evolution for seamless data flow, and utilizes efficient Change Data Capture (CDC) for real-time updates. Select only the columns you need, and leverage our dbt integration for powerful data transformations.
Enterprise Support with SLAs
Airbyte Self-Managed Enterprise comes with dedicated support and guaranteed service level agreements (SLAs), ensuring that your data movement infrastructure remains reliable and performant, and expert assistance is available when needed.
What our users say

Raman Singh
Predictable, straightforward pricing model that simplified budgeting and significantly reduced overall spend

Chase Zieman

“Airbyte helped us accelerate our progress by years, compared to our competitors. We don’t need to worry about connectors and focus on creating value for our users instead of building infrastructure. That’s priceless. The time and energy saved allows us to disrupt and grow faster.”

Rupak Patel
"With Airbyte, we could just push a few buttons, allow API access, and bring all the data into Google BigQuery. By blending all the different marketing data sources, we can gain valuable insights."
How to Sync to Manually
Step 1: Access the New York Times API
First, you need to obtain access to the New York Times API to fetch data. Visit the New York Times Developer Network at https://developer.nytimes.com, create an account, and generate an API key for the services you want to access, such as articles, archives, or any other available endpoint.
Step 2: Retrieve Data Using Python
Use Python to make HTTP requests to the New York Times API. Utilize the `requests` library to send GET requests and retrieve data. For example, you can use the following script to fetch articles:
```python
import requests
api_key = 'your_api_key'
url = 'https://api.nytimes.com/svc/search/v2/articlesearch.json'
params = {
'q': 'your_query',
'api-key': api_key
}
response = requests.get(url, params=params)
data = response.json()
```
Step 3: Transform Data into a Suitable Format
Once you have retrieved the data, transform it into a format suitable for insertion into TiDB. This typically involves converting the JSON response into a structured format like CSV or directly into SQL insert statements. Use Python's `pandas` library for handling and transforming data efficiently.
```python
import pandas as pd
articles = data['response']['docs']
df = pd.json_normalize(articles)
df.to_csv('articles.csv', index=False)
```
Step 4: Prepare TiDB Environment
Ensure that your TiDB environment is ready for data insertion. This involves setting up TiDB on your local machine or in a cloud environment. You can download TiDB from https://pingcap.com/download/ and follow the installation instructions for your operating system. Ensure that you have access credentials and know the hostname, port, username, and password to connect to your TiDB instance.
Step 5: Create a Database and Table in TiDB
Before inserting data, create a database and a corresponding table in TiDB where the data will reside. Use a MySQL client or command line client to execute SQL commands:
```sql
CREATE DATABASE nytimes_data;
USE nytimes_data;
CREATE TABLE articles (
id VARCHAR(255) PRIMARY KEY,
headline TEXT,
pub_date DATETIME,
web_url TEXT,
snippet TEXT
);
```
Step 6: Load Data into TiDB
Load the transformed data into TiDB. You can use the TiDB command line tools or a Python script with a MySQL connector to insert data. If using a CSV file, consider using the `LOAD DATA` SQL command:
```sql
LOAD DATA LOCAL INFILE 'articles.csv'
INTO TABLE articles
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES;
```
Alternatively, use Python with `mysql-connector-python`:
```python
import mysql.connector
connection = mysql.connector.connect(
host='your_tidb_host',
user='your_username',
password='your_password',
database='nytimes_data'
)
cursor = connection.cursor()
for index, row in df.iterrows():
cursor.execute("""
INSERT INTO articles (id, headline, pub_date, web_url, snippet)
VALUES (%s, %s, %s, %s, %s)
""", (row['id'], row['headline.main'], row['pub_date'], row['web_url'], row['snippet']))
connection.commit()
cursor.close()
connection.close()
```
Step 7: Verify Data Integrity and Consistency
After the data load, it's crucial to verify that the data in TiDB matches what was retrieved from the New York Times API. You can do this by running SELECT queries and comparing the result with your local data file or script outputs. Ensure that all records are inserted and that there are no discrepancies or errors during the load process.