Welcome to the DiveAccess API documentation. This API allows you to retrieve Industry Dive articles based on various search parameters. It's designed to work with Large Language Models (LLMs) via Retrieval Augmented Generation (RAG), enhancing the capabilities of AI models with up-to-date, high-quality and domain-specific content.
Follow these steps to get up and running with the DiveAccess API.
A list of Industry Dive article objects will be returned in JSON format.
Industry Dive is a leading business journalism company that provides in-depth, industry-specific news and analysis. Through the DiveAccess API, you will have the ability to fetch articles from Industry Dive publications including Retail Dive, Food Dive, Marketing Dive, CIO Dive and many more. A full list of Industry Dive's 37 publications can be found here.
Each published article is indexed in Elasticsearch and ordered by date. A call to the API base URL without any parameters will return the 10 most recent articles published across all publications. Adding the query parameter will perform a keyword index search on Industry Dive's content and return the most relevant articles for that query, ordered by date.
The DiveAccess API supports various query parameters to refine your search. None of the parameters are required.
Responses are returned in JSON format, containing an array of article objects. Each object includes properties such as title, publication, date, and content.
We have additional query parameter support available and will be adding these capabilities to paid plans in the near future.
Below is an example of the JSON response you will receive from the DiveAccess API. The response contains two main parts: num_found and article_set.
Each article object in the article_set includes the following key information:
The DiveAccess API can be seamlessly integrated with OpenAI's function calling feature to significantly enhance your AI model's capabilities. This integration allows your model to dynamically fetch and incorporate up-to-date, industry-specific information into its responses. Key benefits of this integration include real-time access to the latest industry news and trends with guaranteed high-quality content. This example demonstrates how to use the DiveAccess API as a tool for retrieving relevant articles based on user queries. We'll walk through the process of:
By following this example, you'll be able to create a powerful AI assistant that can provide informed responses on various industry topics, backed by the latest articles from Industry Dive publications.
1from openai import OpenAI
2import requests
3import json
4
5client = OpenAI()
6BASE_URL = "https://api.diveaccess.com/articles"
7ACCESS_KEY = "YOUR_ACCESS_KEY_HERE"
8
9def get_articles(query, from_date=None, to_date=None):
10 """
11 Fetch articles from the DiveAccess API based on the given query and optional date range.
12 """
13 params = {
14 "access_key": ACCESS_KEY,
15 "query": query,
16 }
17 if from_date:
18 params["from_date"] = from_date
19 if to_date:
20 params["to_date"] = to_date
21
22 response = requests.get(BASE_URL, params=params)
23 if response.status_code == 200:
24 return json.dumps(response.json())
25 else:
26 return json.dumps({
27 "error": f"Error: {response.status_code}, {response.text}"
28 })
29
30tools = [
31 {
32 "type": "function",
33 "function": {
34 "name": "get_articles",
35 "description": "Get articles from Industry Dive publications based on keywords extracted from user input. " +
36 "Tool will return a list of articles. " +
37 "Should be used when the message indicates the need for information about a specific topic.",
38 "parameters": {
39 "type": "object",
40 "properties": {
41 "query": {
42 "type": "string",
43 "description": "The search query for articles extracted from the user message."
44 },
45 "from_date": {
46 "type": "string",
47 "description": "Start date for article search (YYYY-MM-DD)." +
48 "The default is 30 days ago. Only include when a specific time frame is necessary.",
49 },
50 "to_date": {
51 "type": "string",
52 "description": "End date for article search (YYYY-MM-DD)." +
53 "The default is today. Only include when a specific time frame is necessary.",
54 },
55 },
56 "required": ["query"],
57 },
58 },
59 }
60]
61
62def run_conversation():
63 prompt = (
64 "What are the latest developments in artificial intelligence? "
65 "Include sources and links where applicable."
66 )
67 messages = [{
68 "role": "user",
69 "content": prompt
70 }]
71
72 response = client.chat.completions.create(
73 model="gpt-4o",
74 messages=messages,
75 tools=tools,
76 tool_choice="auto",
77 )
78 response_message = response.choices[0].message
79 tool_calls = response_message.tool_calls
80
81 if tool_calls:
82 messages.append(response_message)
83 for tool_call in tool_calls:
84 function_name = tool_call.function.name
85 function_args = json.loads(tool_call.function.arguments)
86 function_response = get_articles(
87 query=function_args.get("query"),
88 from_date=function_args.get("from_date"),
89 to_date=function_args.get("to_date"),
90 )
91 messages.append(
92 {
93 "tool_call_id": tool_call.id,
94 "role": "tool",
95 "name": function_name,
96 "content": function_response,
97 }
98 )
99
100 second_response = client.chat.completions.create(
101 model="gpt-4o",
102 messages=messages,
103 )
104
105 return second_response
106 else:
107 return response
108
109print(run_conversation())
The DiveAccess API can be seamlessly integrated with Anthropic's Claude AI model using its function calling feature. This integration allows Claude to dynamically fetch and incorporate up-to-date, industry-specific information into its responses. Key benefits of this integration include real-time access to the latest industry news and trends with guaranteed high-quality content. This example demonstrates how to use the DiveAccess API as a tool for retrieving relevant articles based on user queries with Claude. We'll walk through the process of:
By following this example, you'll be able to create a powerful AI assistant that can provide informed responses on various industry topics, backed by the latest articles from Industry Dive publications.
1import anthropic
2import requests
3import json
4
5client = anthropic.Anthropic()
6BASE_URL = "https://api.diveaccess.com/articles"
7ACCESS_KEY = "YOUR_ACCESS_KEY_HERE"
8
9def get_articles(query, from_date=None, to_date=None):
10 """
11 Fetch articles from the DiveAccess API based on the given query and optional date range
12 """
13 params = {
14 "access_key": ACCESS_KEY,
15 "query": query,
16 }
17 if from_date:
18 params["from_date"] = from_date
19 if to_date:
20 params["to_date"] = to_date
21
22 response = requests.get(BASE_URL, params=params)
23 if response.status_code == 200:
24 return response.json()
25 else:
26 return {"error": f"Error: {response.status_code}, {response.text}"}
27
28tools = [
29 {
30 "name": "get_articles",
31 "description": "Get articles from Industry Dive publications based on keywords extracted from user input. " +
32 "Tool will return a list of articles. " +
33 "Should be used when the message indicates the need for information about a specific topic.",
34 "input_schema": {
35 "type": "object",
36 "properties": {
37 "query": {
38 "type": "string",
39 "description": "The search query for articles extracted from the user message.",
40 },
41 "from_date": {
42 "type": "string",
43 "description": "Start date for article search (YYYY-MM-DD)." +
44 "The default is 30 days ago. Only include when a specific time frame is necessary.",
45 },
46 "to_date": {
47 "type": "string",
48 "description": "End date for article search (YYYY-MM-DD)." +
49 "The default is today. Only include when a specific time frame is necessary.",
50 },
51 },
52 "required": ["query"]
53 }
54 }
55]
56
57def run_conversation():
58 prompt = (
59 "What are the latest developments in artificial intelligence? "
60 "Include sources and links where applicable."
61 )
62
63 # First API call to get tool use
64 response = client.messages.create(
65 model="claude-3-5-sonnet-20240620",
66 max_tokens=1024,
67 tools=tools,
68 messages=[{
69 "role": "user",
70 "content": prompt
71 }]
72 )
73
74 # Check if the model used the tool
75 tool_use = next((content for content in response.content if content.type == "tool_use"), None)
76
77 if tool_use:
78 # If tool was used, fetch articles and make a second API call
79 articles = get_articles(**tool_use.input)
80
81 second_response = client.messages.create(
82 model="claude-3-5-sonnet-20240620",
83 max_tokens=1024,
84 tools=tools,
85 messages=[
86 {
87 "role": "user",
88 "content": prompt
89 },
90 {
91 "role": "assistant",
92 "content": response.content
93 },
94 {
95 "role": "user",
96 "content": [
97 {
98 "type": "tool_result",
99 "tool_use_id": tool_use.id,
100 "content": json.dumps(articles)
101 }
102 ]
103 }
104 ]
105 )
106
107 return second_response
108
109 else:
110 # If no tool was used, return the first response
111 return response
112
113print(run_conversation())