Erste Schritte mit der Library API
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Mit der Library API können Sie in der Google Fotos-Galerie Ihrer Nutzer mit Fotos, Videos und Alben interagieren. Dabei steht Ihnen ein wichtiger Punkt im Vordergrund: Sie können nur auf Inhalte zugreifen und diese verwalten, die von Ihrer Anwendung erstellt wurden.
Vorbereitung
Wichtige Anwendungsfälle der Library API
Die Library API eignet sich ideal für Szenarien, in denen Ihre App Folgendes tun muss:
- Medien hochladen und speichern: Sie können Fotos und Videos, die von Ihrer App generiert wurden, sicher in die Google Fotos-Galerien Ihrer Nutzer importieren.
- Inhalte organisieren: Sie können Alben erstellen und verwalten, um Nutzern bei der Organisation ihrer app-bezogenen Medien zu helfen.
- Fotos und Alben optimieren:Füge Medienelementen und Alben durch Anreicherungen wie Titel, Beschreibungen oder Standortinformationen Kontext hinzu.
- Auf von der App erstellte Daten zugreifen:Fotos, Videos und Alben, die von Ihrer App erstellt wurden, abrufen und damit interagieren.
Typischer Workflow für die Library API
Die Library API bietet verschiedene Funktionen. Ein gängiger Workflow kann die folgenden Schritte umfassen:
Medien hochladen: Über den Endpunkt für Uploads können Sie Foto- oder Video-Bytes sicher in Google Fotos hochladen. In diesem Schritt wird eine uploadToken
generiert.
Medienelemente erstellen: Verwende die mediaItems.batchCreate
-Methode und gib uploadToken
an, um Medienelemente in der Mediathek des Nutzers zu erstellen.
Alben erstellen (optional): Mit der albums.create
-Methode lassen sich Alben in der Mediathek des Nutzers erstellen, um die Medienelemente zu organisieren.
Alben verwalten
Auf von Apps erstellte Medien zugreifen:
- Mit
mediaItems.get
oder mediaItems.batchGet
können Sie Details zu bestimmten Medienelementen abrufen.
- Mit
mediaItems.search
können Sie nach Medienelementen suchen, die von Ihrer App erstellt wurden.
- Mit
mediaItems.search
und der Album-ID können Sie Medienelemente in einem bestimmten von der App erstellten Album auflisten.
Nächste Schritte
- Referenzdokumente lesen: In der detaillierten Referenzdokumentation zur Library API finden Sie Informationen zu allen verfügbaren Methoden und Parametern.
- Beispiele ausprobieren: In unserem Beispiel sehen Sie die Library API in Aktion und können sich Anregungen für Ihre Integration holen.
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-08-29 (UTC).
[null,null,["Zuletzt aktualisiert: 2025-08-29 (UTC)."],[[["\u003cp\u003eThe Library API allows your application to interact with photos, videos, and albums in users' Google Photos libraries, but only for content created by your application.\u003c/p\u003e\n"],["\u003cp\u003eKey use cases include uploading/storing media, organizing content into albums, enhancing media with details, and accessing previously created app data.\u003c/p\u003e\n"],["\u003cp\u003eA typical workflow involves uploading media, creating media items, optionally creating and managing albums, and accessing the app-created media.\u003c/p\u003e\n"],["\u003cp\u003eBefore starting, ensure the Library API aligns with your needs by reviewing the overview and configuring your app for API access.\u003c/p\u003e\n"]]],["The Library API enables interaction with Google Photos, specifically for app-created content. Key actions include uploading media using an `uploadToken`, creating media items in the user's library, and optionally organizing them into albums. You can also manage albums by adding or removing media, adding enrichments, and retrieving album information. The API allows retrieval and searching of app-created media items. The first step before starting to use this API is to configure your application and ensure the Library API is suitable for your use case.\n"],null,["# Get started with the Library API\n\nThe Library API lets you to interact with photos, videos, and albums within your\nusers' Google Photos libraries, but with an important focus: you can only access\nand manage content that was created by your application.\n\nBefore you start\n----------------\n\n- **Check out the overview:** [Compare the Picker API and the Library API](/photos/overview/about) to make sure the Library API is the right fit for your use case.\n- **Configure Your app:** Enable the API and set up authentication. See [Configure your app](/photos/overview/configure-your-app) for detailed steps.\n\nKey use cases of the Library API\n--------------------------------\n\nThe Library API is ideal for scenarios where your app needs to:\n\n- **Upload and store media:** Securely import photos and videos (generated by your app) into your users' Google Photos libraries.\n- **Organize content:** Create and manage albums to help users organize their app-related media.\n- **Enhance photos and albums:** Add context to media items and albums through enrichments like titles, descriptions, or location information.\n- **Access app-created data:** Retrieve and interact with the photos, videos, and albums that your app has previously created.\n\nTypical Library API workflow\n----------------------------\n\nWhile the Library API offers various functionalities, a common workflow might\ninvolve these steps:\n\n1. **Upload media:** Use the [uploads endpoint](/photos/library/guides/upload-media)\n to securely upload photo or video bytes to Google Photos. This step\n generates an\n [`uploadToken`](/photos/library/reference/rest/v1/mediaItems/batchCreate#SimpleMediaItem.FIELDS.upload_token).\n\n2. **Create media items:** Use the [`mediaItems.batchCreate`\n method](/photos/library/guides/upload-media#creating-media-item), providing\n the `uploadToken`, to create media items in the user's library.\n\n3. **Create albums (optional):** Use the [`albums.create` method](/photos/library/guides/manage-albums#creating-new-album)\n to create albums within the user's library to organize the media items.\n\n4. **Manage albums:**\n\n - Add media items (created by your app) to albums using [`albums.batchAddMediaItems`.](/photos/library/guides/manage-albums#adding-items-to-album)\n - Remove media items from albums using [`albums.batchRemoveMediaItems`](/photos/library/guides/manage-albums#removing-items-from-album).\n - Add enrichments to albums (like titles or locations) using [`albums.addEnrichment`.](/photos/library/guides/add-enrichments#intro-adding-enrichments-album)\n - Retrieve information about specific albums using [`albums.get`](/photos/library/guides/list#listing-albums).\n - List albums created by your app using [`albums.list`](/photos/library/guides/list#listing-albums).\n5. **Access app-created media:**\n\n - Retrieve details about specific media items using `mediaItems.get` or `mediaItems.batchGet`.\n - Search for media items created by your app using `mediaItems.search`.\n - List media items within a specific app-created album using `mediaItems.search` with the album ID.\n\nNext steps\n----------\n\n- Review the reference docs: Explore the detailed [Library API reference\n documentation](/photos/library/reference/rest) to learn about all the available methods and parameters.\n- Try out the samples: Check out our [sample](/photos/library/samples) to see the Library API in action and get inspiration for your integration."]]