how to get data for a crypto on coinmarketcap api when there is multiple crypto with the same name - cryptocurrency

i'm trying to get the data for a crypto named Jade protocol but when i call jade in my search it give me the data for Jade currency.
i'm using a simple call:
https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=BTC,JADE,CRO,TIME

I would prefer to use only ID or at least slugs in queries to avoid such problems.
The slug can be found in the URL of the coin (coinmarketcap.com/currencies/jade-protocol/), but it is better to call CoinMarketCap ID Map and find there the ID or slug by the name of the coin (in case the slug ever changes).

Related

Next.js - How to show post name in the url instead of the id and make it unique?

I searched for this but I could only find examples in Laravel and PHP, and I need to know how to do this with Next.js.
All I know is that I can do dynamic routes in Next.js the usual way like this ...
/pages/post/[postId] which will translate to /pages/post/23435 for example, and that way if someone has the URL I could just grab the [postId] with router.query and can show the correct post to the user, easy enough.
But what if I want to show the post name in the URL instead of the id? just like what Udemy does with dashes between the words ...
https://www.udemy.com/course/your-custom-react-component/learn/lecture/
And at the same time if someone has that URL I could still show the correct post to them?
I know I could just do /pages/post/[postName] and show the post name in the URL, but that won't be unique, and won't be able to show the correct post.
How can I do that?
You can to do it with postName as you propose, and then take care that postNames are unique and that each one maps to a postId (that's something you need to deal with on your side; so in your database you would generate a unique slug for each postName)
Another solution would be to show both the name and the id like /pages/post/[postName]/[postId]. You can use several params, check https://nextjs.org/docs/routing/dynamic-routes

Set Title and Id With Retrieve and Rank Web Interface

I have used IBM Watson Retrieve and Rank Web Interface to create a collection of html articles. Via the web interface I was able to upload my html articles. The problem is when I query the collection the data for id and title are not usable. Here is the query I made in the browser:
https://MY-USER-NAME:MY-PASSWORD#gateway.watsonplatform.net/retrieve-and-rank/api/v1/solr_clusters/MY-CLUSTER/solr/MY-COLLECTION/select?q=what is the basic mechanism of the transonic aileron buzz&wt=json&fl=id,title
The response I get is:
{"responseHeader":{"status":0,"QTime":106,"params":{"q":"what is the basic mechanism of the transonic aileron buzz","fl":"id,title","wt":"json"}},"response":{"numFound":12,"start":0,"docs":[{"id":"6a06f47c-cb3f-4791-9914-c84772eb9415","title":"no-title"}.....
The bold section is the problem. When using the web interface is there a way to set the title and id when uploading documents? Or, better yet, is there another way I query my collection to get the file name of the document I uploaded and/or the text from the document?
When using the web interface is there a way to set the title and id when uploading documents?
No, sorry.
However, if you upload the documents yourself from outside of the web interface, you can specify the title and ID (and the documents will be shown in the web interface when you come back to it).
is there another way I query my collection to get the file name of the document I uploaded
Yes
In the query you posted above, the last parameters you have are the fields you want to retrieve
&fl=id,title
You're retrieving the ID and the title.
If you want the name of the file that the content came from, add fileName. For example:
https://MY-USER-NAME:MY-PASSWORD#gateway.watsonplatform.net/retrieve-and-rank/api/v1/solr_clusters/MY-CLUSTER/solr/MY-COLLECTION/select?q=what is the basic mechanism of the transonic aileron buzz&wt=json&fl=id,title,fileName
is there another way I query my collection to get text from the document
Yes.
Similar to above, you just need to update the list of fields that you retrieve. The contents of the doc is put in a field called body.
So to get the ID, title, and the body, you could use:
https://MY-USER-NAME:MY-PASSWORD#gateway.watsonplatform.net/retrieve-and-rank/api/v1/solr_clusters/MY-CLUSTER/solr/MY-COLLECTION/select?q=what is the basic mechanism of the transonic aileron buzz&wt=json&fl=id,title,body
That gets you a plain text version of the contents. If you want the HTML, use contentHtml instead.
https://MY-USER-NAME:MY-PASSWORD#gateway.watsonplatform.net/retrieve-and-rank/api/v1/solr_clusters/MY-CLUSTER/solr/MY-COLLECTION/select?q=what is the basic mechanism of the transonic aileron buzz&wt=json&fl=id,title,contentHtml

How to use and map alias string instead of id in UI-Router

Usually I use ui-router state with id parameter like this:
/* route /news/{news_id} */
http://servername/#‌​/news/14
but already I want to use alias string instead of id like this:
/* route /news/{news_title} */
http://servername/#‌​/news/braking-news-of-usa
How to map news_title to news_id in angular or ui-router?
I don't think this specific to Angular, but you can consider following approaches.
Along with title append news id with some separator. e.g. breaking_news_of_usa_14. When someone clicks that link, in Javascript split the news title and retrieve the ID to query server API.
Make sure you have unique titles for news (overhead at serverside API e.g. unique index, hashes etc.) and instead of querying with news id, query using news title to get the details.
Maintain both news ID and news title like this /{news_title/{news_id}. With this you save overhead of introducing unique titles. (Reference, check stackoverflow URL format for question details.)

use mongoDB ObjectID in query parameter, does it affect SEO?

if we use object id of mongodb in query parameter like for example,
in browser url,
http://example.com/get-details/507f191e810c19729de860ea
to pass this objectID from one state to another state, I am using $stateparam
then,in $http
the url will be
"/get_details?id="+$stateParams.detail_id
$http.get("/get_details?id="+$stateParams.detail_id).then(...);
if there any problem with the url in browser in terms of SEO, i.e, http://example.com/get-details/507f191e810c19729de860ea what could be the solution
It's OK to use MongoDB Object ID as a primary key in a URL, in terms of SEO.
Also please consider including a slugified title along with the Object ID in the URL:
http://example.com/detail/<Object-ID>/<Slug>
It makes the URL more readable and helps search engines to determine the content of your page.

Publishing photo to Facebook via Graph API: OAuthException: (#100) param tags must be an array

I'm attempting to upload a photo to Facebook via the Graph API on a test user account for my app. With just the url, link, name parameters present, the upload works fine returning a valid photo id.
However, if I use the additional tags parameter, I end up with the following error returned:
{
"error": {
"message": "(#100) param tags must be an array.",
"type": "OAuthException",
"code": 100
}
}
I've tried to provide the value for tags in almost every possible way I can think of, as I know the Graph API isn't straightforward (even the parameter url which is used to upload a photo from a URL isn't listed under the photo Graph API method);
A single user id
tags=100003919104407
Multiple CS'd user ids
tags=100003919104407,100003919104408,100003919104409
Array with ids not as integers
tags=[100003919104407, 100003919104404,100003919104405]
Array with ids as strings
tags=["100003919104407", "100003919104404","100003919104405"]
Array containing objects, as per the Facebook Graph API documentation
tags=[{"id":"100003919104407"},{"id":"100003919104404"},{"id":"100003919104405"}]
If someone could tell me the right format/another parameter through which to pass user ids in order to have them tagged in a photo, I'd be very grateful.
Try this
It should be in this format
[{"to":"100003919104407","x":0,"y":0},
{"to":"100003919104408","x":10,"y":10},
{"to":"100003919104409","x":20,"y":20}]
or
[{"tag_uid":"100003919104407","x":0,"y":0},
{"tag_uid":"100003919104408","x":10,"y":10},
{"tag_uid":"100003919104409","x":20,"y":20}]
Where did you get your information from? Have you check the tags section?
Create
You can create a tag on the photo by issuing an HTTP POST request to
the tags connection, PHOTO_ID/tags.
Note: This feature is intended to help users tag their friends in real
photos. You should not use this feature to encourage users to tag
their friends if their friends are not actually in that photo, or to
tag friends in composite photos. If your app is found to be
encouraging this behavior, your usage of this feature may be disabled.
You can specify which user to tag using two methods: in the URL path
as PHOTO_ID/tags/USER_ID, or in a URL parameter as
PHOTO_ID/tags?to=USER_ID. To add several tags at once, you can specify
a tags property which contains an array of tags like so
PHOTO_ID/tags?tags=[{"id":"1234"}, {"id":"12345"}]. Currently, you
cannot tag a Page in a photo using this API.
There's also an example.
the X and Y value of array need to be %, not in pixels
Example 1 (wrong)
img:(640,480) xy:(320,240)
[{tag_uid:user_id,x:320,y:240}] <- wrong, because 320 > 100%
Example 2 (right)
img:(640,480) xy:(320,240) px:(320,240) < %
[{tag_uid:user_id,x:50,y:50}] <- right, because 50 < 100%

Resources