• Cynber
    link
    2
    edit-2
    9 months ago

    This is great!

    Quick API question for anyone, does the search API only look at the post body field? When I try searching for a particular link (say a news article), it only seems to pull posts where the link was mentioned in the body, not when the link was the submission

    • @[email protected]
      link
      fedilink
      English
      1
      edit-2
      9 months ago

      Set type_ to "Url" and q to the URL.

      https://lemmy.readme.io/reference/search-1


      EDIT: Just from my own experimentation, it seems that ‘All’ doesn’t include ‘Url’. I can get a result with type_=Url, but if I change it to type_=All then that result isn’t included. I can’t find this documented anywhere, but it seems to be the case.

      example requests and responses with curl showing this

      Ex. 1. type_=All

      REQUEST WITH type_=All (note: I ran into problems with terminal escape character when just pasting this into my shell, so it’s probably most reliable if you paste this into a file and run it)

      curl --request GET \
           --url 'https://lemmy.world/api/v3/search?q=https%3A%2F%2Fwww.businessinsider.com%2Fmountains-switzerland-collapsing-from-permafrost-melt-2023-8%3Fr%3DUS%26IR%3DT&type_=All' \
           --header 'accept: application/json'
      

      RESPONSE FOR type_=All

      {"type_":"All","comments":[],"posts":[],"communities":[],"users":[]}
      

      Ex. 2. type_=Url

      REQUEST WITH type_=Url (note: I ran into problems with terminal escape character when just pasting this into my shell, so it’s probably most reliable if you paste this into a file and run it)

      curl --request GET \
           --url 'https://lemmy.world/api/v3/search?q=https%3A%2F%2Fwww.businessinsider.com%2Fmountains-switzerland-collapsing-from-permafrost-melt-2023-8%3Fr%3DUS%26IR%3DT&type_=Url' \
           --header 'accept: application/json'
      

      RESPONSE WITH type_=Url

      {"type_":"Url","comments":[],"posts":[{"post":{"id":3251548,"name":"Mountains are collapsing: A Swiss mountain peak fell apart, sending 3.5 million cubic feet of rock into the valley below.","url":"https://www.businessinsider.com/mountains-switzerland-collapsing-from-permafrost-melt-2023-8?r=US&IR=T","body":"Mt. Fluchthorn's tallest peak, on the Swiss-Austrian border, collapsed in June.\n\nExperts say peaks in the European Alps and Southern Alps of New Zealand are at risk of collapse, too.\n\nThe damage and dangers from mountain collapse disproportionately impact indigenous communities.\n\n\nOn June 11, the main peak of Mt. Fluchthorn, on the border of Austria and Switzerland, collapsed without warning.\n\nRoughly 3.5 million cubic feet of earth tumbled down, filling the valley below with 40 Olympic swimming pools' worth of rocks, mud, and dirt, LiveScience reported. While no people got hurt, a religious cross marking the summit was destroyed.\n\nFluchthorn had three peaks, and the main, southern one used to be the tallest. With the south peak collapsed, the middle peak is the new summit at 11,145 feet — the second-highest summit in the Silvretta Alps.\n\nOverall, Mt. Fluchthorn is 60 feet shorter than it was earlier this year, per LiveScience.\n\nWhy did the peak collapse? Well, like many mountains in the far north, Fluchthorn had a lot of permafrost — a permanent layer of ice and dirt under the mountain's surface.\n\n\"Permafrost is important because frozen water within the ground holds the ground surface together and prevents it from moving. But when that ice melts, the liquid water can flow away. The ground surface becomes less stable and can move, often very quickly,\" said Jasper Knight, a geoscientist at the University of Witwatersrand in South Africa.\n\nWhen a big chunk of mountain moves quickly, like with the mudslide at Fluchthorn, that's called a mass movement.\n\n\"Global warming is causing the permafrost to melt, which is the trigger for these mass movement events to take place,\" Knight said.","creator_id":222917,"community_id":32,"removed":false,"locked":false,"published":"2023-08-15T21:47:11.222191","deleted":false,"nsfw":false,"embed_title":"Mountains are collapsing: A Swiss mountain peak fell apart, sending 3.5 million cubic feet of rock into the valley below. Scientists warn climate change could make more mountains crumble.","embed_description":"Mt. Fluchthorn's tallest peak collapsed earlier this year, and it's just one of many crumbling examples most likely to come within the next decade.","thumbnail_url":"https://lemmy.ml/pictrs/image/9918782b-d6b1-4efa-baca-84e908963c1b.jpeg","ap_id":"https://lemm.ee/post/4388122","local":false,"language_id":37,"featured_community":false,"featured_local":false},"creator":{"id":222917,"name":"Woland","display_name":"Woland","avatar":"https://lemm.ee/pictrs/image/b3b54374-93a2-48e0-a860-4d04ee497f2c.jpeg","banned":false,"published":"2023-06-18T09:23:52.832330","actor_id":"https://lemm.ee/u/Woland","local":false,"deleted":false,"admin":false,"bot_account":false,"instance_id":626},"community":{"id":32,"name":"worldnews","title":"World News","description":"News from around the world!\n\n# Rules:\n\n* Please only post links to actual news sources, no tabloid sites, etc\n\n* No NSFW content\n\n* No hate speech, bigotry, propaganda, etc","removed":false,"published":"2019-10-18T20:41:31.638738","updated":"2021-01-28T22:42:57.262164","deleted":false,"nsfw":false,"actor_id":"https://lemmy.ml/c/worldnews","local":false,"icon":"https://lemmy.ml/pictrs/image/gWmVEUZ94Z.png","hidden":false,"posting_restricted_to_mods":false,"instance_id":3},"creator_banned_from_community":false,"counts":{"id":537133,"post_id":3251548,"comments":8,"score":87,"upvotes":91,"downvotes":4,"published":"2023-08-15T21:47:11.222191","newest_comment_time_necro":"2023-08-16T00:12:28","newest_comment_time":"2023-08-16T00:12:28","featured_community":false,"featured_local":false,"hot_rank":1120,"hot_rank_active":3864,"community_id":32,"creator_id":222917},"subscribed":"NotSubscribed","saved":false,"read":false,"creator_blocked":false,"unread_comments":8}],"communities":[],"users":[]}
      
      • Cynber
        link
        29 months ago

        Oh interesting, thank you! That’s really helpful :)