Lemmy API Examples
  • "Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearME
    megaman1970
    Now 100%

    Thanks, I'll revamp my code when I start testing it later. I think eventually I'll put together a python library for interacting with Lemmy, or at least give enough of an example that someone else can get a good start.

    1
  • Why did Microsoft Build VSCode? Turns out, GitHub Copilot.
  • "Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearME
    megaman1970
    Now 100%

    I just use ChatGPT with JetBrains tools, it works pretty well. Make sure you go for the paid model, though. It really is better than the free one, and I often use it to lay groundwork that I flesh out in the free model.

    1
  • Lemmy API Examples
  • "Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearME
    megaman1970
    Now 100%

    Here's a kind of guess on how to create a post using python's requests library:

    import requests
    import json
    
    # Define the URL for the API endpoint
    url = "https://lemmy.ml/api/v1/post"
    
    # Define the headers for the request
    headers = {'Content-Type': 'application/json'}
    
    # Define the data for the new post
    data = {
     "name": "Your Post Title",
     "community_id": 123,  # Replace with your community ID
     "url": "https://your-url.com",  # Optional
     "body": "Your post content",  # Optional
     "nsfw": False,  # Optional
     "language_id": 1,  # Optional, replace with your language ID
     "auth": "your_auth_token_here"
    }
    
    # Send the POST request
    response = requests.post(url, headers=headers, data=json.dumps(data))
    
    # Print the response
    print(response.json())
    

    Does this look right? I understand that I'll have to authenticate to the server to do this, but I'm really not sure how to do that.

    4
  • I'm looking for examples of calls to the Lemmy API.. I've been to the following link in the documentation: https://join-lemmy.org/docs/en/contributors/04-api.html However I don't see any direct examples of uses of the API for common cases, like creating a post, creating a comment or getting either type of item. Some of the linked documentation from that page points to what I believe is typescript code for interfaces, but that does not really have examples of actually *calling* those interfaces. I can make some logical guesses at to what the calls should be, but I don't have a way to really verify this yet. Does anyone have some working examples they can post?

    14
    11
    Megathread for Reddit Blackouts and News - Day 2
  • "Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearME
    megaman1970
    Now 100%

    Has anyone considered creating a bridging API interface for lemmy? Something that can translate between the lemmy and reddit API to make this easier?

    5
  • What's your favorite construct in SQL?
  • "Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearME
    megaman1970
    Now 100%

    Those work, but require a lot of careful structuring to get right, and can be a pain to debug. With a CTE, you can just call on the intermediate steps to trace down problems.

    1
  • For me, it's CTE's. I find it amazing to complete a calculation with clear intermediate steps, and goes a long way towards convincing people to use SQL rather than Excel to perform calculations on large tables of data. What construct do you like using on a daily basis?

    15
    12
    *Permanently Deleted*
  • "Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearME
    megaman1970
    Now 100%

    Well, I do get a lot of alerts from Google as new topics come in, and I could post those links. That's mostly the way things are handled in the Futurology and Science subs. Posting those to Lemmy communities should work, I think. I guess I worry about swamping a community with traffic, but if so, I guess whoever manages that community can let me know to dial it back.

    1
  • *Permanently Deleted*
  • "Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearME
    megaman1970
    Now 100%

    I wasn't thinking about reuploading comments, just submissions. There are a lot of submissions that would be interesting to discuss here as separate conversations away from reddit. For example, Futurology, Science, Finance, and even Aww and Eyebleach have some nice things to discuss.

    4
  • *Permanently Deleted*
  • "Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearME
    megaman1970
    Now 100%

    Is it permissible to transfer the submissions from reddit to lemmy directly, to at least provide a seed to start conversations going?

    4
  • "Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearME
    Now
    3 11

    megaman1970

    beehaw.org