Building Search Queries
To URL-encode your search queries, there are a lot of online websites that can help, such as this one.
Alternatively, most programming languages have some type of built-in support for URL-encoding as well.
Space
In search queries, a space
should be used to denote words that should be grouped together by AND
.
%20
and +
are both used to denote spaces within URLs, with %20
tending to be used before query parameters and +
tending to be used within query parameters. However, either works fine.
Meaning:
https://api.rsplit.io/v1/articles/search?apiKey=*&q=fractional%20shares
https://api.rsplit.io/v1/articles/search?apiKey=*&q=fractional+shares
are both equivalent.
Example Queries:
-
Find articles that mention rounding up any fractional shares that may result from a reverse stock split:
"rounding up"
fractional rounding
fractional "rounding up"
"fractional shares" "rounding up"
-
Find articles that do not mention companies giving cash-in-lieu of fractional shares:
-"cash-in-lieue"
-
Find articles mentioning companies having Computershare as their transfer agent and that are not rounding down fractional shares:
computershare -"rounding down"
URL-Encoding Support
As mentioned above, most programming languages offer built-in support for URL-encoding. Say we want to use the following query: fractional shares -"rounding"
- Go
- Java
- Javascript
- Python
package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
v := url.Values{}
v.Add("q", `fractional shares -"rounding"`)
apiUrl := fmt.Sprintf("https://api.rsplit.io/v1/articles/search?apiKey=YOUR_API_KEY&%s", v.Encode())
resp, err := http.Get(url)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading body:", err)
return
}
fmt.Println(string(body))
}
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
public class HttpTest {
public static void main(String[] args) throws IOException, InterruptedException{
String searchQuery = URLEncoder.encode("fractional shares -\"rounding\"", StandardCharsets.UTF_8);
String url = String.format("https://api.rsplit.io/v1/articles/search?apiKey=YOUR_API_KEY&q=%s", searchQuery);
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.timeout(Duration.ofSeconds(10))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
const baseURL = 'https://api.rsplit.io/v1/articles/search?';
const apiKey = 'YOUR_API_KEY';
const query = 'fractional shares -"rounding"';
const apiURL = `${apiURL}apiKey=${apiKey}&q=${encodeURIComponent(query)}`;
fetch(apiURL, {method: 'GET'})
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
import requests
param_value = requests.utils.quote('fractional shares -"rounding"')
url = f'https://api.rsplit.io/v1/articles/search?apiKey=YOUR_API_KEY&q={param_value}'
response = requests.get(url)
print(response.json())