Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added custom API widget #1858

Merged
merged 2 commits into from
Aug 26, 2023
Merged

Added custom API widget #1858

merged 2 commits into from
Aug 26, 2023

Conversation

denispapec
Copy link
Contributor

Proposed change

This adds support for custom self-hosted API and third party API.
Detailed usage can be found in docs: benphelps/homepage-docs#147

For the simplicity of testing, examples use public API that is not interesting for homepage usage 😅
image

Public API example 1
        widget:
          type: custom
          url: https://api.open-meteo.com/v1/forecast?latitude=52.52&longitude=13.41&current_weather=true&hourly=temperature_2m,relativehumidity_2m,windspeed_10m
          refreshInterval: 60000
          mappings:
            - field:
                hourly:
                  time: 108
              label: Hour
            - field:
                hourly:
                  temperature_2m: 108
              format: number
              label: Temperature
            - field:
                hourly:
                  relativehumidity_2m: 108
              label: Humidity
              format: percent
Public API example 2
        widget:
          type: custom
          url: https://rickandmortyapi.com/api/character/1
          mappings:
            - field: name
              label: Name
            - field: status
              label: Status
            - field:
                origin: name
              label: Origin
            - field:
                location: name
              label: Location
Public API example 3
        widget:
          type: custom
          url: https://pokeapi.co/api/v2/pokemon/ditto
          refreshInterval: 5000
          mappings:
            - field: name
              label: Name
            - field:
                moves:
                  0:
                    move: name
              label: Main move

Closes #1219

Type of change

  • New service widget
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Other (please explain)

Checklist:

  • If adding a service widget or a change that requires it, I have added a corresponding PR to the documentation here: Added custom API widget - docs benphelps/homepage-docs#147
  • If adding a new widget I have reviewed the guidelines.
  • If applicable, I have checked that all tests pass with e.g. pnpm lint.
  • If applicable, I have tested my code for new features & regressions on both mobile & desktop devices, using the latest version of major browsers.

@shamoon
Copy link
Collaborator

shamoon commented Aug 26, 2023

Cool idea. A little nervous about the "support" requests 😅 but this is clever, I think people will dig it. I can take a look soon

@shamoon
Copy link
Collaborator

shamoon commented Aug 26, 2023

Two small things in the meantime:

  • i think we should rename this to something like "custom json" or "custom api"? Thinking we want to leave room for other widgets of the custom ilk
    - we need to enforce a minimum refresh, other places use 1500 (resources use 1000 but 1500 more consistent with service widgets) I see you did already =)

@shamoon
Copy link
Collaborator

shamoon commented Aug 26, 2023

Nice mate. I did go ahead and rename it, just to preserve the namespace. And I saw you already had the refresh minimum.

Thanks, I think people will dig this.

Screenshot 2023-08-25 at 11 37 53 PM (thats calibre-web done here)

@shamoon shamoon merged commit fc7e73e into gethomepage:main Aug 26, 2023
1 check failed
@janek202
Copy link

janek202 commented Aug 26, 2023

Thank you for this widget, it works great!

Is there a way to use this widget with an API key?
I tried integrating it with Syncthing REST API (https://docs.syncthing.net/dev/rest) using 'key: API_KEY', and 'password: API_KEY', but it doesn't seem to be working for me.
The documentation doesn't mention API keys, /rest/noauth/health works fine.

Sorry, if this is not the right place to ask.

Copy link
Contributor

github-actions bot commented Feb 5, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion or issue for related concerns.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 5, 2024
@denispapec denispapec deleted the widget-custom branch May 5, 2024 15:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants