Trying to get autocomplete to work in my app when searching for companies.
In my case i am searching for "ska"
Three (3) diffenrent scenarios:
1 - Go to https://www.linkedin.com/ta/federator?types=company&query=ska in your browser.
Result: You get json response with data.
2. Try calling it via javascript
Front-End
$("#birds").autocomplete({
minLength: 3,
source: function (request, response) {
// request.term is the term searched for.
// response is the callback function you must call to update the autocomplete's
// suggestion list.
$.ajax({
url: "https://www.linkedin.com/ta/federator?types=company",
data: { query: request.term },
dataType: "json",
success: response,
error: function () {
response([]);
}
});
}
});
Result: Null
Scenario 3:
Make a call to the LinkedIn API with your APi and secret key.
API Call the "company-search?keywords={your-partial-word}"
Result: The searchhits is nothing like the autocomplete. The autocomplete suggestions are much better.
Suggestions on how to build a autocomlete for LinkedIn when searching for comapnies only.
As mentioned there are two different ways.
Calling the https://www.linkedin.com/ta/federator?types=company&query={name}
Using LinkedIn API - not good nor expected result as shown when using (1)
I think a good way to do this is:
Build a local server, which could handle your request to query, and send your query to linkedin query url(This would eliminate the CORS problem)
In that autocomplete js code, set the url to be your local server.
Related
This problem made me crazy, I have to present my app in 2 days, today morning everything was working well, then after lunch, without touching anything I have an event error and my app doen't work anymore this is very very frustrating.
The errors happens when I call the Play endpoint of the spotify Api :
https://developer.spotify.com/console/put-play/?device_id=&body=%7B"uris"%3A%5B"spotify%3Atrack%3A7fODjB7BrQTGqh0hogW6XD"%5D%7D
by this simple code :
$("#playSong").click(()=> {
const deviceId = sessionStorage.getItem("deviceId")
$.ajax({
url: "https://api.spotify.com/v1/me/player/play?device_id="+ deviceId,
type: "put",
data: JSON.stringify({
uris : ["spotify:track:0adsXJdRMoumQY1ECzEjWf"]
}),
headers: {
"Content-Type":"application/json" ,
Authorization: "Bearer " + sessionStorage.getItem("idPlateforme")
}
})
})
Token and deviceId are correct and working fine.
The query above returns a success response, though it seems that the web playback sdk sends internally 2 queries that returns 400 not every time
the first query :
https://cpapi.spotify.com/v1/client/90f40750108390a7ed2b62af9e94e58a4763bd15/event/item_ready
with these datas :
{"timestamp":1662798866395,"player_state":{"playback_id":"454eba51905ada7d8e086bda7726f6d2","duration":278181,"current_position":0,"paused":false,"playbackQuality":{"hifi_status":"NONE","audio_quality":"VERY_HIGH"}},"playback_descriptor_id":"CIDQDxANGgVBVURJTw==","initial_loading_stats":{}}
Its error message is this :
Playback updates are only acceptable once the playback has started
The second one which also returns 400 error :
https://cpapi.spotify.com/v1/client/90f40750108390a7ed2b62af9e94e58a4763bd15/event/resume
with datas :
{"timestamp":1662798867712,"player_state":{"playback_id":"454eba51905ada7d8e086bda7726f6d2","duration":278229,"current_position":0,"paused":false,"playbackQuality":{"hifi_status":"NONE","audio_quality":"VERY_HIGH"}},"playback_descriptor_id":"CIDQDxANGgVBVURJTw=="}
everything was tested on a simple HTML page like the example here on all known browsers : https://developer.spotify.com/documentation/web-playback-sdk/quick-start/
and still doesn't work on any
I know it's nothing to do with MY code, a possible bug ?
Please I need help
my first post on stackoverflow btw
Google Sheets with RapidAPI
First time trying to get APIs to work! I thought a simple project would be to get a Googlesheet to retrieve movie information based on the title.
Googling around I happened upon RapidAPI which has a Googlesheets add-on. Unfortunately I haven't found much useful documentation so have hit a dead end.
What I've learned so far
There only seems to be one example for how to implement it... by using the =GET() command like so (in this case for pulling finance info):
=GET(”https://investors-exchange-iex-trading.p.rapidapi.com/stock/{symbol}/book”,”quote.companyName”,”YOUR_API_KEY_HERE”,”symbol”,”AAPL”)
I couldn't get this example to work, and the IMDB Code Snippet seems a little different, so I'm not sure how that works at all. Not the curly bracers around {symbol}.
var axios = require("axios").default;
var options = {
method: 'GET',
url: 'https://imdb8.p.rapidapi.com/title/find',
params: {q: 'Dredd'},
headers: {
'x-rapidapi-host': 'imdb8.p.rapidapi.com',
'x-rapidapi-key': '5840855726msh193dee7e1600046p145eddjsnc66aff778896'
}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
When I run a typical search on IMDB, I get a URL that looks like this:
https://www.imdb.com/find?q=dredd&ref_=nv_sr_sm
I notice this q parameter there, which seems important...
I'm not sure how I am meant to format this =GET() command for IMDB data. The example suggests one thing, but Googlesheets suggests another: "GET(url, selectPaths, rapidApiKey)"
I'm not sure what the curly bracers are doing in the example URL.
Whatever I try seems to give the same error message:
Error
Request failed for https://imdb8.p.rapidapi.com returned code 400. Truncated server response: 400 - Bad Request (use muteHttpExceptions option to examine full response) (line 98).
Send Help
Does anyone have a better, working tutorial for using this setup? Or could you direct me to some useful reading material that a layperson could understand?
I found a good resource for you. Check out this well-written article on RapidAPI's official blog.
https://rapidapi.com/blog/api-google-sheets/
I try to get all results of a TestCase via API. In the UI I see a list of all results of a TC via the following url:
https://dev.azure.com/xxx/yyyy/_testPlans/_results?testCaseId=48587
How can I do this via API?
How can I do this via API?
I am afraid that you couldn't find this API in Official document.
But you could get the API in Browser console:
Here are the API and Request Body:
API URL:
POST https://dev.azure.com/{OrganizationName}/_apis/Contribution/HierarchyQuery?excludeUrls=true&enumsAsNumbers=true&msDateFormat=true&noArrayWrap=true&api-version=5.0-preview.1
Request Body:
{
"contributionIds":["ms.vss-test-web.testcase-results-data-provider"],
"dataProviderContext":
{"properties":
{
"testCaseId":testcaseid,
"sourcePage":{"url":"https://dev.azure.com/{OrganizationName}/{ProjectName}/_testPlans/execute?planId={TestPlanId}&suiteId={Test SuiteID}","routeId":"ms.vss-test-web.testplans-hub-refresh-route","routeValues":{"project":"{ProjectName}","pivots":"execute","controller":"ContributedPage","action":"Execute"}}
}
}
}
Result:
If you want to get detailed info, you could pass the Test Run id and test result ID to Rest API: Results - Get
I'm trying to write a react native app which will stream some tracks from Soundcloud. As a test, I've been playing with the API using python, and I'm able to make requests to resolve the url, pull the playlists/tracks, and everything else I need.
With that said, when making a request to the stream_url of any given track, I get a 401 error.
The current url in question is:
https://api.soundcloud.com/tracks/699691660/stream?client_id=PGBAyVqBYXvDBjeaz3kSsHAMnr1fndq1
I've tried it without the ?client_id..., I have tried replacing the ? with &, I've tried getting another client_id, I've tried it with allow_redirects as both true and false, but nothing seems to work. Any help would be greatly appreciated.
The streamable property of every track is True, so it shouldn't be a permissions issue.
Edit:
After doing a bit of research, I've found a semi-successful workaround. The /stream endpoint of the API is still not working, but if you change your destination endpoint to http://feeds.soundcloud.com/users/soundcloud:users:/sounds.rss, it'll give you an RSS feed that's (mostly) the same as what you'd get by using the tracks or playlists API endpoint.
The link contained therein can be streamed.
Okay, I think I have found a generalized solution that will work for most people. I wish it were easier, but it's the simplest thing I've found yet.
Use API to pull tracks from user. You can use linked_partitioning and the next_href property to gather everything because there's a maximum limit of 200 tracks per call.
Using the data pulled down in the JSON, you can use the permalink_url key to get the same thing you would type into the browser.
Make a request to the permalink_url and access the HTML. You'll need to do some parsing, but the url you'll want will be something to the effect of:
"https://api-v2.soundcloud.com/media/soundcloud:tracks:488625309/c0d9b93d-4a34-4ccf-8e16-7a87cfaa9f79/stream/progressive"
You could probably use a regex to parse this out simply.
Make a request to this url adding ?client_id=... and it'll give you YET ANOTHER url in its return json.
Using the url returned from the previous step, you can link directly to that in the browser, and it'll take you to your track content. I checked on VLC by inputting the link and it streams correctly.
Hopefully this helps some of you out with your developing.
Since I have the same problem, the answer from #Default motivated me to look for a solution. But I did not understand the workaround with the permalink_url in the steps 2 and 3. The easier solution could be:
Fetch for example user track likes using api-v2 endpoint like this:
https://api-v2.soundcloud.com/users/<user_id>/track_likes?client_id=<client_id>
In the response we can finde the needed URL like mentioned from #Default in his answer:
collection: [
{
track: {
media: {
transcodings:[
...
{
url: "https://api-v2.soundcloud.com/media/soundcloud:tracks:713339251/0ab1d60e-e417-4918-b10f-81d572b862dd/stream/progressive"
...
}
]
}
}
...
]
Make request to this URL with client_id as a query param and you get another URL with that you can stream/download the track
Note that the api-v2 is still not public and the request from your client probably will be blocked by CORS.
As mentioned by #user208685 the solution can be a bit simpler by using the SoundCloud API v2:
Obtain the track ID (e.g. using the public API at https://developers.soundcloud.com/docs)
Get JSON from https://api-v2.soundcloud.com/tracks/TRACK_ID?client_id=CLIENT_ID
From JSON parse MP3 progressive stream URL
From stream URL get MP3 file URL
Play media from MP3 file URL
Note: This link is only valid for a limited amount of time and can be regenerated by repeating steps 3. to 5.
Example in node (with node-fetch):
const clientId = 'YOUR_CLIENT_ID';
(async () => {
let response = await fetch(`https://api.soundcloud.com/resolve?url=https://soundcloud.com/d-o-lestrade/gabriel-ananda-maceo-plex-solitary-daze-original-mix&client_id=${clientId}`);
const track = await response.json();
const trackId = track.id;
response = await fetch(`https://api-v2.soundcloud.com/tracks/${trackId}?client_id=${clientId}`);
const trackV2 = await response.json();
const streamUrl = trackV2.media.transcodings.filter(
transcoding => transcoding.format.protocol === 'progressive'
)[0].url;
response = await fetch(`${streamUrl}?client_id=${clientId}`);
const stream = await response.json();
const mp3Url = stream.url;
console.log(mp3Url);
})();
For a similar solution in Python, check this GitHub issue: https://github.com/soundcloud/soundcloud-python/issues/87
I am trying to get JSON data from SportsRadar using an API request. My trial url is:
http://api.sportradar.us/nba/trial/v4/en/games/2018/03/03/schedule.json?api_key=4j9ge4a4rgsbq597f29p9rgb
When I copy this url into my google browser, the data I get back is as expected, but when I try to use/add the API request to my meteor project the API request does not return any data. As a test, in my client/main.js file I have added:
HTTP.call('GET',Meteor.absoluteUrl("http://api.sportradar.us/nba/trial/v4/en/games/2018/03/03/schedule.json?api_key=4j9ge4a4rgsbq597f29p9rgb"),
function(err,result){
console.log(result.data);
});
The console log result come back as null. Any guidance or thoughts will be appreciated - cfp
You need to call your callback function correctly. Try this;
HTTP.call('GET','http://api.sportradar.us/nba/trial/v4/en/games/2018/03/03/schedule.json?api_key=4j9ge4a4rgsbq597f29p9rgb'),
function(err,result){
if (result) {
console.log(result.data);
}
console.log(err);
});
Edit: The parameters of The HTTP.call() is corrected by removing Meteor.absoluteUrl()in the question upon Derrick's comment below.
You can also refer to the official documentation here.