### JavaScript Example for SourceForge API Source: https://docs.sourceforge.net/lists-buyer-intent-activity This snippet provides an example of how to interact with the SourceForge API using JavaScript. It is intended to show a client-side or server-side implementation for making API calls. Specific details on dependencies or exact usage are not provided in this context. ```javascript fetch('https://sourceforge.net/rest/p/sfapi/v1/activities?bsl_id=integer%3Cint32%3E&date_from=string&date_to=string', { method: 'GET', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }) .then(response => { if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return response.json(); }) .then(data => { console.log(data); }) .catch(error => { console.error('Error fetching activities:', error); }); ``` -------------------------------- ### Fetch BSLs from SourceForge API (Ruby) Source: https://docs.sourceforge.net/lists-business-software-listings-bsls Shows how to fetch BSL data from the SourceForge API using Ruby's built-in `net/http` and `json` libraries. This example sets the necessary `Accept` and `Content-Type` headers for the GET request and prints the response body. ```ruby require "uri" require "json" require "net/http" url = URI("https://sourceforge.net/rest/p/sfapi/v1/bsls") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["Accept"] = "application/json" request["Content-Type"] = "application/json" response = https.request(request) puts response.read_body ``` -------------------------------- ### Retrieve Segments Data using JavaScript Source: https://docs.sourceforge.net/lists-buyer-intent-segments This JavaScript code example shows how to make a GET request to the SourceForge API's segments endpoint using the `fetch` API. It includes setting up necessary headers and handling the response. The `bsl_id` parameter is a placeholder for an integer. ```javascript var myHeaders = new Headers(); myHeaders.append("Accept", "application/json"); myHeaders.append("Content-Type", "application/json"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("https://sourceforge.net/rest/p/sfapi/v1/segments?bsl_id=integer", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` -------------------------------- ### Example SourceForge Buyer Intent Activity Data Structure (JSON) Source: https://docs.sourceforge.net/crm-buyer-intent-api-integration This JSON structure represents the response received from the SourceForge `/activities` API endpoint. It contains an array of 'data' objects, each detailing visitor information (country, city, visitor ID), company details (name, domain, industry, size), and a list of activities performed by the visitor, including activity type, URL, and date. ```json { "data": [ { "visitor": { "country": "United States", "city": "Mission", "functional_area": null, "region": "Texas", "visitor_id": "7d07c9ec-81e3-4c5a-9002-f04356808f2a" }, "activities": [ { "activity_id": 85301199, "target": "competitor", "type": "comparison", "action": "view", "url": "https://slashdot.org/software/comparison/Microsoft-Teams-vs-YuJa-vs-Zoom-Video-Conferencing/", "count": 2, "date": "2024-12-02", "site_visited": "Slashdot.org" } ], "company": { "name": "UTRGV - The University of Texas Rio Grande Valley", "domain": "utrgv.edu", "country": "United States", "company_size": "Large (1,000 - 4,999 Employees)", "headquarters": "USA, Brownsville", "industry": "Education > Colleges & Universities", "revenue": "XLarge ($200MM-$1B)", "linkedin": "https://www.linkedin.com/company/4815498", "hq_country_code": "US", "hq_city": "Brownsville", "hq_postal_code": null } } ] } ``` -------------------------------- ### API Endpoint Example with Bearer Token Source: https://docs.sourceforge.net/buyer-intent-api-documentation Demonstrates how to include the obtained Bearer token in the Authorization header for making API requests. ```APIDOC ## API Endpoint Example with Bearer Token ### Description This example shows how to authenticate a GET request to the `/rest/p/sfapi/v1/bsls` endpoint using a Bearer token. ### Method GET ### Endpoint https://sourceforge.net/rest/p/sfapi/v1/bsls ### Parameters #### Headers - **Authorization** (string) - Required - The access token prefixed with "Bearer ". Example: `Bearer 5gTw2cPt6e7eLFmlleqCesAaa3Ukfd` ### Request Example ```text GET https://sourceforge.net/rest/p/sfapi/v1/bsls Authorization: Bearer 5gTw2cPt6e7eLFmlleqCesAaa3Ukfd ``` ``` -------------------------------- ### GET /rest/p/sfapi/v1/activities Source: https://docs.sourceforge.net/crm-buyer-intent-api-integration Retrieves buyer intent activity data from SourceForge. Authentication is required, and you need to provide your Bearer token, bsl_id, date_from, and date_to parameters. ```APIDOC ## GET /rest/p/sfapi/v1/activities ### Description Retrieves buyer intent activity data. This endpoint requires authentication and specific query parameters to filter the results. ### Method GET ### Endpoint https://sourceforge.net/rest/p/sfapi/v1/activities ### Parameters #### Query Parameters - **bsl_id** (string) - Required - Your unique BSL ID. - **date_from** (string) - Required - The start date for the data range (YYYY-MM-DD). - **date_to** (string) - Required - The end date for the data range (YYYY-MM-DD). #### Headers - **Authorization** (string) - Required - Bearer YOUR_SOURCEFORGE_BEARER_TOKEN - **Accept** (string) - Required - application/json - **Content-Type** (string) - Required - application/json ### Request Example ```curl curl -G -H "Authorization: Bearer YOUR_SOURCEFORGE_BEARER_TOKEN" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ --data-urlencode "bsl_id=YOUR_BSL_ID" \ --data-urlencode "date_from=2023-01-01" \ --data-urlencode "date_to=2023-01-31" \ https://sourceforge.net/rest/p/sfapi/v1/activities ``` ### Response #### Success Response (200) - **data** (array) - Contains a list of buyer intent activities. - **visitor** (object) - Information about the visitor. - **country** (string) - The visitor's country. - **city** (string) - The visitor's city. - **visitor_id** (string) - The unique ID of the visitor. - **activities** (array) - A list of activities performed by the visitor. - **activity_id** (integer) - The ID of the activity. - **target** (string) - The target of the activity (e.g., 'competitor'). - **type** (string) - The type of activity (e.g., 'comparison'). - **action** (string) - The action taken (e.g., 'view'). - **url** (string) - The URL visited. - **count** (integer) - The number of times the activity occurred. - **date** (string) - The date of the activity (YYYY-MM-DD). - **site_visited** (string) - The site where the activity occurred. - **company** (object) - Information about the company the visitor belongs to. - **name** (string) - The company name. - **domain** (string) - The company domain. - **country** (string) - The company's country. - **industry** (string) - The company's industry. - **linkedin** (string) - The company's LinkedIn profile URL. #### Response Example ```json { "data": [ { "visitor": { "country": "United States", "city": "Mission", "visitor_id": "7d07c9ec-81e3-4c5a-9002-f04356808f2a" }, "activities": [ { "activity_id": 85301199, "target": "competitor", "type": "comparison", "action": "view", "url": "https://slashdot.org/software/comparison/Microsoft-Teams-vs-YuJa-vs-Zoom-Video-Conferencing/", "count": 2, "date": "2024-12-02", "site_visited": "Slashdot.org" } ], "company": { "name": "UTRGV - The University of Texas Rio Grande Valley", "domain": "utrgv.edu", "country": "United States", "industry": "Education > Colleges & Universities", "linkedin": "https://www.linkedin.com/company/4815498" } } ] } ``` ``` -------------------------------- ### Fetch Project Activities using JavaScript Source: https://docs.sourceforge.net/lists-buyer-intent-activity This JavaScript code snippet demonstrates how to fetch project activities from the SourceForge API using the `fetch` API. It sets up request headers for JSON content and logs the response or any errors. The endpoint requires `bsl_id`, `date_from`, and `date_to` parameters. ```javascript var myHeaders = new Headers(); myHeaders.append("Accept", "application/json"); myHeaders.append("Content-Type", "application/json"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("https://sourceforge.net/rest/p/sfapi/v1/activities?bsl_id=integer&date_from=string&date_to=string", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` -------------------------------- ### Fetch Project Activities using Python Source: https://docs.sourceforge.net/lists-buyer-intent-activity This Python code snippet demonstrates fetching project activities from the SourceForge API using the `requests` library. It defines the API endpoint URL and sets up the required headers for JSON content. The code sends a GET request and prints the text content of the response. The endpoint requires `bsl_id`, `date_from`, and `date_to` parameters. ```python import requests import json url = "https://sourceforge.net/rest/p/sfapi/v1/activities?bsl_id=integer&date_from=string&date_to=string" payload = {} headers = { 'Accept': 'application/json', 'Content-Type': 'application/json' } response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Fetch Project Activities using Ruby Source: https://docs.sourceforge.net/lists-buyer-intent-activity This Ruby code snippet shows how to retrieve project activities from the SourceForge API. It utilizes the `net/http` and `json` libraries to construct and send a GET request. The request includes necessary headers, and the response body is printed to the console. The endpoint requires `bsl_id`, `date_from`, and `date_to` parameters. ```ruby require "uri" require "json" require "net/http" url = URI("https://sourceforge.net/rest/p/sfapi/v1/activities?bsl_id=integer&date_from=string&date_to=string") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) request["Accept"] = "application/json" request["Content-Type"] = "application/json" response = https.request(request) puts response.read_body ``` -------------------------------- ### Fetch Activities using cURL Source: https://docs.sourceforge.net/lists-buyer-intent-activity This snippet demonstrates how to fetch activities from the SourceForge API using cURL. It specifies the endpoint URL and required headers for making the request. The parameters `bsl_id`, `date_from`, and `date_to` are placeholders for integer and string values, respectively. ```curl curl --location 'https://sourceforge.net/rest/p/sfapi/v1/activities?bsl_id=integer%3Cint32%3E&date_from=string&date_to=string' \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' ``` -------------------------------- ### Fetch BSLs from SourceForge API (JavaScript) Source: https://docs.sourceforge.net/lists-business-software-listings-bsls Demonstrates how to make a GET request to the SourceForge API to retrieve BSL data using the `fetch` API in JavaScript. It includes setting request headers for JSON content and handling the response, logging either the result or any errors. ```javascript var myHeaders = new Headers(); myHeaders.append("Accept", "application/json"); myHeaders.append("Content-Type", "application/json"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("https://sourceforge.net/rest/p/sfapi/v1/bsls", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` -------------------------------- ### GET /rest/p/sfapi/v1/activities Source: https://docs.sourceforge.net/lists-buyer-intent-activity Retrieves a list of activities for a given project. Supports filtering by date range. ```APIDOC ## GET /rest/p/sfapi/v1/activities ### Description Retrieves a list of activities for a given project. Supports filtering by date range. ### Method GET ### Endpoint `/rest/p/sfapi/v1/activities` ### Parameters #### Query Parameters - **bsl_id** (integer) - Required - The ID of the project. - **date_from** (string) - Optional - The start date for filtering activities (format: YYYY-MM-DD). - **date_to** (string) - Optional - The end date for filtering activities (format: YYYY-MM-DD). ### Request Example ```json { "example": "curl --location 'https://sourceforge.net/rest/p/sfapi/v1/activities?bsl_id=integer%3Cint32%3E&date_from=string&date_to=string' \ --header 'Accept: application/json' \ --header 'Content-Type: application/json'" } ``` ### Response #### Success Response (200) - **activities** (array) - A list of activity objects. - **id** (string) - The unique identifier for the activity. - **title** (string) - The title of the activity. - **url** (string) - The URL to the activity. - **published** (string) - The publication date and time of the activity. - **content** (string) - A summary or description of the activity. - **author** (object) - Information about the author of the activity. - **name** (string) - The name of the author. - **url** (string) - The URL to the author's profile. - **project** (object) - Information about the project the activity belongs to. - **name** (string) - The name of the project. - **url** (string) - The URL to the project. #### Response Example ```json { "example": "{\"activities\": [{\"id\": \"12345\", \"title\": \"New Release Available\", \"url\": \"http://example.com/activity/12345\", \"published\": \"2023-10-27T10:00:00Z\", \"content\": \"Version 1.0 has been released.\", \"author\": {\"name\": \"John Doe\", \"url\": \"http://example.com/users/johndoe\"}, \"project\": {\"name\": \"MyProject\", \"url\": \"http://example.com/projects/myproject\"}}] }" } ``` #### Error Responses - **400 Bad Request**: Returned if the request parameters are invalid. - **message** (string) - Description of the error. - **401 Unauthorized**: Returned if the request lacks valid authentication credentials. - **message** (string) - Description of the error. - **404 Not Found**: Returned if the requested resource (e.g., project) does not exist. - **message** (string) - Description of the error. - **429 Too Many Requests**: Returned if the rate limit has been exceeded. - **message** (string) - Description of the error. ``` -------------------------------- ### GET /rest/p/sfapi/v1/segments Source: https://docs.sourceforge.net/lists-buyer-intent-segments Retrieves the buyer intent segments defined for a given Business Software Listing (BSL). ```APIDOC ## GET /rest/p/sfapi/v1/segments ### Description Gets the segments defined for a Business Software Listing (BSL). ### Method GET ### Endpoint https://sourceforge.net/rest/p/sfapi/v1/segments ### Parameters #### Query Parameters - **bsl_id** (integer) - Required - Id of the BSL to query #### Header Parameters - **Authorization** (string) - Optional - Bearer token for authentication ### Request Example ```bash curl -X GET "https://sourceforge.net/rest/p/sfapi/v1/segments?bsl_id=123" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" ``` ### Response #### Success Response (200) - **data** (array) - An array of segment objects. - **id** (integer) - The unique identifier for the segment. - **segment_name** (string) - The name of the segment. - **company** (array) - A list of companies associated with the segment. - **exclude_companies** (boolean) - Flag indicating if companies are excluded from this segment. - **country** (array) - A list of countries associated with the segment. - **region** (string) - The region associated with the segment. - **categories** (array) - A list of categories associated with the segment. - **products** (array) - A list of products associated with the segment. - **company_size** (array) - A list of company sizes associated with the segment. - **industry** (array) - A list of industries associated with the segment. #### Response Example ```json { "data": [ { "id": 1, "segment_name": "Business Segment", "company": [ "Google", "Microsoft" ], "exclude_companies": false, "country": [ "United Kingdom" ], "region": "EURO", "categories": [ "IT Management", "Data Center Management" ], "products": [ "Microsoft", "Google" ], "company_size": [ "Medium (200 - 499 Employees)" ], "industry": [ "Technology" ] } ] } ``` ``` -------------------------------- ### List BSLs using cURL Source: https://docs.sourceforge.net/lists-business-software-listings-bsls This snippet demonstrates how to list Business Software Listings (BSLs) using the cURL command-line tool. It sends a GET request to the specified API endpoint and includes necessary headers for JSON content. ```curl curl --location 'https://sourceforge.net/rest/p/sfapi/v1/bsls' \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' ``` -------------------------------- ### GET /rest/p/sfapi/v1/segments Source: https://docs.sourceforge.net/lists-buyer-intent-segments Retrieves segments based on provided parameters. Supports filtering by search term and category. ```APIDOC ## GET /rest/p/sfapi/v1/segments ### Description Retrieves segments based on provided parameters. Supports filtering by search term and category. ### Method GET ### Endpoint /rest/p/sfapi/v1/segments ### Parameters #### Query Parameters - **bsl_id** (integer) - Required - The ID of the business logic segment. - **search_term** (string) - Optional - A term to search for within segments. #### Request Body This endpoint does not accept a request body. ### Response #### Success Response (200) - **example** (string[]) - An array of strings representing the found segments. Example: `["Software > Business Intelligence"]` #### Error Responses - **400 Bad Request**: Returned if the request parameters are invalid. The response body may contain a `message` field with details. - **401 Unauthorized**: Returned if the request lacks proper authentication or permissions. The response body may contain a `message` field. - **404 Not Found**: Returned if the requested segments are not found. The response body may contain a `message` field. - **429 Too Many Requests**: Returned if the rate limit has been exceeded. The response body may contain a `message` field. #### Response Example (200) ```json [ "Software > Business Intelligence" ] ``` ``` -------------------------------- ### GET /rest/p/sfapi/v1/activities Source: https://docs.sourceforge.net/lists-buyer-intent-activity Retrieves a list of activities for a given project. You can filter activities by providing a BSL ID and a date range. ```APIDOC ## GET /rest/p/sfapi/v1/activities ### Description Retrieves a list of activities for a given project. You can filter activities by providing a BSL ID and a date range. ### Method GET ### Endpoint `https://sourceforge.net/rest/p/sfapi/v1/activities` ### Parameters #### Query Parameters - **bsl_id** (integer) - Required - The BSL ID to filter activities by. - **date_from** (string) - Optional - The start date for filtering activities (format: YYYY-MM-DD). - **date_to** (string) - Optional - The end date for filtering activities (format: YYYY-MM-DD). ### Request Example ``` GET https://sourceforge.net/rest/p/sfapi/v1/activities?bsl_id=12345&date_from=2024-01-01&date_to=2024-01-31 ``` ### Response #### Success Response (200) - **data** (array) - An array of activity objects. - **visitor** (object) - Information about the visitor. - **visitor_id** (string) - Unique identifier for the visitor. - **display_name** (string) - Display name of the visitor. - **email** (string) - Email address of the visitor. - **linkedin_url** (string) - LinkedIn profile URL of the visitor. - **country** (string) - Country of the visitor. - **region** (string) - Region of the visitor. - **city** (string) - City of the visitor. - **functional_area** (string) - Functional area of the visitor's profession. - **seniority** (string) - Seniority level of the visitor. - **professional_group** (string) - Professional group of the visitor. - **activities** (array) - A list of activities performed by the visitor. - **activity_id** (integer) - Unique identifier for the activity. - **date** (string) - Date of the activity (YYYY-MM-DD). - **url** (string) - URL related to the activity. - **target** (string) - The target of the activity. - **type** (string) - The type of activity. - **action** (string) - The action performed. - **site_visited** (string) - The site visited. - **count** (integer) - The number of times the activity occurred. - **company** (object) - Information about the company the visitor is associated with. - **name** (string) - Name of the company. - **domain** (string) - Domain name of the company. - **country** (string) - Country of the company. - **size** (string) - Size of the company. - **industry** (string) - Industry of the company. - **revenue** (string) - Revenue of the company. - **headquarters** (string) - Headquarters location of the company. - **hq_country_code** (string) - Country code of the company headquarters. - **hq_state** (string) - State of the company headquarters. - **hq_city** (string) - City of the company headquarters. - **hq_postal_code** (string) - Postal code of the company headquarters. - **linkedin** (string) - LinkedIn profile URL of the company. #### Response Example (200 OK) ```json { "data": [ { "visitor": { "visitor_id": "75492bad-74c2-405c-9453-ead3a03b6856", "display_name": "John Doe", "email": "john.doe@mail.com", "linkedin_url": "linkedin.com/in/johndoe", "country": "United States", "region": "North Carolina", "city": "Charlotte", "functional_area": "Education", "seniority": "Management", "professional_group": "IT Professional / Business Professional" }, "activities": [ { "activity_id": 83206197, "date": "2024-06-17", "url": "https://sourceforge.net/software/crm/", "target": "category", "type": "category_page", "action": "view", "site_visited": "SourceForge.net", "count": 1 } ], "company": { "name": "Stony Brook University", "domain": "stonybrook.edu", "country": "United States", "size": "Large (1,000 - 4,999 Employees)", "industry": "Education > Colleges & Universities", "revenue": "XXLarge ($1B+)", "headquarters": "USA, Stony Brook", "hq_country_code": "US", "hq_state": "New York", "hq_city": "Stony Brook", "hq_postal_code": "11794", "linkedin": "https://www.linkedin.com/company/7201" } } ] } ``` #### Error Response (400 Bad Request) ```json { "message": "Invalid request parameters" } ``` #### Error Response (401 Unauthorized) ```json { "message": "Permission denied" } ``` #### Error Response (404 Not Found) ```json { "message": "Activities not found" } ``` #### Error Response (429 Too Many Requests) ```json { "message": "Rate limit exceeded" } ``` ```