-
Notifications
You must be signed in to change notification settings - Fork 26
Add Nostr Java API reference documentation #384
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
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request adds comprehensive API reference documentation for the Nostr Java library. The documentation covers the public APIs across all modules including identity management, event model, WebSocket clients, encryption, and utility functions.
Key Changes:
- Creates a new API reference document with complete coverage of public interfaces
- Provides method signatures, usage examples, and links to relevant NIPs
- Organizes content by module with clear sections for identity, events, clients, encryption, and utilities
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| public NostrIF setRelays(Map<String,String> relays) | ||
| public List<String> sendEvent(IEvent event) | ||
| public List<String> sendRequest(List<Filters> filters, String subscriptionId) | ||
| public NostrIF sign(Identity identity, ISignable signable) |
Copilot
AI
Aug 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sign method documentation suggests it returns a NostrIF but the method signature indicates it modifies state and returns the client instance. This pattern could be confusing - consider clarifying if this is a fluent interface or if the method actually performs signing internally.
| ```java | ||
| Filters filters = new Filters(new AuthorFilter(pubKey)); | ||
| NostrIF client = NostrSpringWebSocketClient.getInstance(id); | ||
| List<String> events = client.sendRequest(filters, "sub-id"); |
Copilot
AI
Aug 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example shows sendRequest returning List<String> events, but based on the method signature at line 97, it should return List<String> representing request IDs, not events. The variable name 'events' is misleading and should be something like 'requestIds' or 'responses'.
| List<String> events = client.sendRequest(filters, "sub-id"); | |
| List<String> requestIds = client.sendRequest(filters, "sub-id"); |
| ``` | ||
|
|
||
| ### Subscription with Filters | ||
| ```java |
Copilot
AI
Aug 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example uses pubKey variable that is not defined in the code block. This will cause a compilation error. Either define the variable or use a placeholder like somePublicKey.
| ```java | |
| ```java | |
| PublicKey pubKey = id.getPublicKey(); |
| ```java | ||
| Filters filters = new Filters(new AuthorFilter(pubKey)); | ||
| NostrIF client = NostrSpringWebSocketClient.getInstance(id); | ||
| List<String> events = client.sendRequest(filters, "sub-id"); |
Copilot
AI
Aug 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sendRequest method expects List<Filters> as the first parameter according to line 97, but the example passes a single Filters object. This should be Arrays.asList(filters) or List.of(filters).
| List<String> events = client.sendRequest(filters, "sub-id"); | |
| List<String> events = client.sendRequest(List.of(filters), "sub-id"); |
Summary
Testing
mvn -q verify(fails: Could not find a valid Docker environment for Testcontainers)https://chatgpt.com/codex/tasks/task_b_68a48da624788331a2de29cb22a02468